A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by samisaham » Wed Sep 30, 2009 11:35 pm
I am trying to get a hinge joint to function, but am having trouble understanding how the pin of a custom hinge is represented in a matrix.
I think my issue is that I don't understand how Matrix's work well. Would someone please explain how matrix's work or point me to a source that I can learn from, and help me to set the pin of this joint?
Thank you!
- Code: Select all
//Using Newton 2.09 beta
dMatrix matrix;
matrix = GetIdentityMatrix();
matrix.m_posit.m_x = xOrig;
matrix.m_posit.m_y = yOrig;
matrix.m_posit.m_z = zOrig;
//This is my trouble. I have the pin I want, represented by a vector(xPin,yPin,zPin) and I want to apply it to the joint.
//I do not understand how to do this. The code here is my latest of many attempts:
matrix.m_front.m_x = xPin;
matrix.m_front.m_y = yPin;
matrix.m_front.m_z = zPin;
//End trouble area :)
NewtonUserJoint* newHinge;
newHinge = CreateCustomHinge (&matrix[0][0], nChildBody, nParentBody);
-
samisaham
-
- Posts: 15
- Joined: Mon Mar 24, 2008 11:59 am
by Stucuk » Thu Oct 01, 2009 4:23 am
http://en.wikipedia.org/wiki/Matrix_(mathematics)^ Unless you like maths then that won't help.
Matrix's store the Position, Scale(Tho you generally don't touch scale) and Rotation of an Object.
Note: IIRC You don't set the pin in the matrix. Matrix iirc is just where the joint should "sit" between the 2 bodies. Tho i havn't done Joints since 1.53 .
-

Stucuk
-
- Posts: 801
- Joined: Sat Mar 12, 2005 3:54 pm
- Location: Scotland
-
by samisaham » Thu Oct 01, 2009 9:12 am
Thanks for your help!
Unless I'm greatly mistaken, the axis of allowed rotation must be set somewhere?
How would I joint a body to the world allowing it to rotate only around the z-axis, for instance?
-
samisaham
-
- Posts: 15
- Joined: Mon Mar 24, 2008 11:59 am
by JernejL » Thu Oct 01, 2009 10:02 am
samisaham wrote:Thanks for your help!
Unless I'm greatly mistaken, the axis of allowed rotation must be set somewhere?
How would I joint a body to the world allowing it to rotate only around the z-axis, for instance?
create a unit length vector... directed at the Z axis?
-

JernejL
-
- Posts: 1587
- Joined: Mon Dec 06, 2004 2:00 pm
- Location: Slovenia
-
by samisaham » Thu Oct 01, 2009 1:36 pm
Sorry if I'm missing the obvious -
newHinge = CreateCustomHinge (&matrix[0][0], nChildBody, nParentBody);
How do I construct a matrix that contains both my origin of joint, and pin direction vector to pass to this function from JointLibrary.dll?
-
samisaham
-
- Posts: 15
- Joined: Mon Mar 24, 2008 11:59 am
by samisaham » Thu Oct 01, 2009 3:50 pm
ah! I think I've got it working:
- Code: Select all
dVector pin(xPin,yPin,zPin);
matrix = dgGrammSchmidt(pin);
matrix.m_posit.m_x += xOrig;
matrix.m_posit.m_y += yOrig;
matrix.m_posit.m_z += zOrig;
Simple, but had to pull dgGrammSchmidt() out of 1.53 matrix implimentation
-
samisaham
-
- Posts: 15
- Joined: Mon Mar 24, 2008 11:59 am
by Julio Jerez » Thu Oct 01, 2009 4:17 pm
It is in the dMass class
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by samisaham » Sat Oct 10, 2009 9:20 am
Thanks
My copy seriously was missing it. I must have corrupted the file somehow... I looked in the .rar and it is in there. All up and running now! Thanks for your help
-
samisaham
-
- Posts: 15
- Joined: Mon Mar 24, 2008 11:59 am
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 3 guests