Joint Axis (specifically slider joint)

A place to discuss everything related to Newton Dynamics.

Moderators: Sascha Willems, walaber

Joint Axis (specifically slider joint)

Postby martinw » Fri Aug 06, 2010 11:22 am

Hi,

This is probably a very simple question and I apologise if it is but it's driving me to distraction :oops:

I am trying to programatically insert a joint into a 3D world and as it says in the subject it's a simple slider joint.

The problem I'm having is with the slider joint axis. I have the rotation of the body I want to attach the joint to in degrees (+/-180) but using Sin and Cos I cannot get the slider joint to work when I set the vector for the slider joint axis.

I can intialise a slider joint with an axis of (1, 0, 0) which is the initial orientation of the object and the slider joint works fine but when I try to use the angle of the object when I add additional slider joints by using the angle of the object in the Y direction to provide the slider axis via (cos y angle, 0, sin y angle) it doesn't work. I set up some boundary tests, for example (-1, 0, 0) doesn't seem to work and I though 45 degrees would be (0.707, 0, 0.707) but it doesn't seem to be.

If someone could give me some examples of vectors for 45, 90, 180, -45, -90, -180 I may be able to understand it better?

This is probably very simple but if someone could give me a pointer on this I would appreciate it.

Thanks in advance.

Martin
User avatar
martinw
 
Posts: 30
Joined: Wed Jun 01, 2005 1:19 pm
Location: Aberdeenshire

Re: Joint Axis (specifically slider joint)

Postby Julio Jerez » Fri Aug 06, 2010 1:57 pm

is this newton 2.00 custom joint?
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Joint Axis (specifically slider joint)

Postby martinw » Fri Aug 06, 2010 2:46 pm

Hi Julio,

Yes I think it is, it's integrated into TV3D and from what I can tell the Newton version is 2.07.

http://www.truevision3d.com/forums/news ... 656.0.html

Martin
User avatar
martinw
 
Posts: 30
Joined: Wed Jun 01, 2005 1:19 pm
Location: Aberdeenshire

Re: Joint Axis (specifically slider joint) SOLVED

Postby martinw » Mon Aug 09, 2010 9:18 am

Hi Julio,

The axes of the joints don't seem to have the same polarity as the axes of the 3D environment :oops:

Sorted :D

Martin
User avatar
martinw
 
Posts: 30
Joined: Wed Jun 01, 2005 1:19 pm
Location: Aberdeenshire

Re: Joint Axis (specifically slider joint)

Postby Julio Jerez » Mon Aug 09, 2010 11:33 am

I do not understan what you mean by that polarity, here is a demo from thw SDK that implement a slider joint
Code: Select all
   {
      // ////////////////////////////////////////////////////////////////////////////////////
      //
      // add a sliding visualObject with limits
      //
      NewtonBody* beat;
      CustomSlider* joint;
      RenderPrimitive* visualObject;
      dMatrix beatLocation (location);
      dVector beatSize (0.5f, 2.0f, 2.0f);

      beatLocation.m_posit.m_x += size.m_x * 0.25f;


      // create a collision primitive to be shared by all links
      collision = NewtonCreateBox (nWorld, beatSize.m_x, beatSize.m_y, beatSize.m_z, 0, NULL);

      // create the a graphic character (use a visualObject as our body)
      OGLMesh* visualGeometry;
      visualGeometry = new OGLMesh("box_1", collision, "camo.tga", "camo.tga", "camo.tga");
      visualObject = new RenderPrimitive (beatLocation, visualGeometry);
      system->AddModel___ (visualObject);
      visualObject->Release();

      visualGeometry->Release();

      beat = NewtonCreateBody(nWorld, collision);
      NewtonReleaseCollision (nWorld, collision);

      // attach graphic object to the rigid body
      NewtonBodySetUserData(beat, visualObject);

      // set a destructor function
      NewtonBodySetDestructorCallback (beat, PhysicsBodyDestructor);

      // set the transform call back function
      NewtonBodySetTransformCallback (beat, PhysicsSetTransform);

      // set the force and torque call back function
      NewtonBodySetForceAndTorqueCallback (beat,PhysicsApplyGravityForce);

      // calculate a accurate moment of inertia
      dVector origin;
      dVector inertia;
      NewtonConvexCollisionCalculateInertialMatrix (collision, &inertia[0], &origin[0]);   

      mass = 5.0f;
      Ixx = mass * inertia[0];
      Iyy = mass * inertia[1];
      Izz = mass * inertia[2];


      // set the mass matrix
      NewtonBodySetMassMatrix (beat, mass, Ixx, Iyy, Izz);

      // set the matrix for both the rigid body and the graphic body
      NewtonBodySetMatrix (beat, &beatLocation[0][0]);
      PhysicsSetTransform (beat, &beatLocation[0][0], 0);

      // set the pivot relative for the first bar
      const dMatrix& pinAndPivot = beatLocation;
      joint = new CustomSlider (pinAndPivot, beat, bar);

      // calculate the minimum and maximum limit for this joints
      dFloat minLimits = ((location.m_posit.m_x - beatLocation.m_posit.m_x) - size.m_x * 0.5f);
      dFloat maxLimits = ((location.m_posit.m_x - beatLocation.m_posit.m_x) + size.m_x * 0.5f);

      joint->EnableLimits(true);
      joint->SetLimis (minLimits, maxLimits);
   }



the pin is set in global space in a Matrix, the first row of matrix (the x axis) is the pin vector of the slider
the nextr two rows of the matrix mudt form an orthognal matrix
the reference point for limits is the translation part of the pinandpivotmatrix (the third row)

const dMatrix& pinAndPivot = beatLocation;
joint = new CustomSlider (pinAndPivot, beat, bar);

you can set the pin in any orientation you want, just remmber the pin an pivot matrix is in global space
Julio Jerez
Moderator
Moderator
 
Posts: 12452
Joined: Sun Sep 14, 2003 2:18 pm
Location: Los Angeles

Re: Joint Axis (specifically slider joint)

Postby martinw » Tue Aug 10, 2010 3:59 am

Hi Julio,

Thank you for that, it's much clearer now.

Another quick question on joints, is there any way to stop the joint "stretching"? I set the joint stiffness on by ball and socket joints to 1.0f which I think is the stiffest but when I apply a force the objects between the two joints pull apart or squash together "moving" where the joint is.

I have a rope with ball joints that looks like this _______ and when I pull on the rope it looks like this because the joints stretch _ _ _ _ _ _

Is there any way to stop this?

Thanks.

Martin
User avatar
martinw
 
Posts: 30
Joined: Wed Jun 01, 2005 1:19 pm
Location: Aberdeenshire

Re: Joint Axis (specifically slider joint)

Postby martinw » Wed Aug 18, 2010 3:46 am

OK let's just call it a feature :)
User avatar
martinw
 
Posts: 30
Joined: Wed Jun 01, 2005 1:19 pm
Location: Aberdeenshire


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 389 guests