A place to discuss everything related to Newton Dynamics.
Moderators: Sascha Willems, walaber
by pr0t0z » Tue Apr 23, 2013 10:03 am
Hi all,
I am currently trying to change the NewtonHinge standard Joints for some CustomJoints. However, the interface is slightly different and the problem I have right now is how do I transform a the Pin vector I use into the pinAndPivotFrame matrix required to compute the Local Matrixes (only the rotation matrix, since the position (pivot) is straightforward).
Best Regards,
Carlos
-
pr0t0z
-
- Posts: 15
- Joined: Wed May 30, 2012 11:57 am
by JoeJ » Tue Apr 23, 2013 10:17 am
For me it's easier to ignore the pnaAndPivotframe param from the custom joints constructor, and set both the local matrices directly afterwards.
Something like:
Joint *j = new CustomXXX (..., temporal identity for pin&pivot, ... bodies etc.);
j->localMatrix0 = myJointspaceForBody0;
j->localMatrix1 = myJointspaceForBody1;
... usually you already know the positional part und can find proper orientation by 'pin is mostly x - axis'-rule, or looking at joints submit function or trial and error.
Hope that helps.
-

JoeJ
-
- Posts: 1489
- Joined: Tue Dec 21, 2010 6:18 pm
by JoeJ » Tue Apr 23, 2013 10:29 am
Maybe not the best aswer...
looking at joints submit function there is:
sinAngle = (matrix0.m_up * matrix1.m_up) % matrix0.m_front;
...which means it measures hinge angle from up & front vector.
So the pinAndPivot for constructor should be in worldspace and:
left vector is aligned with hinge axis,
front vector should point in direction where limit angle is zero (if i'm wrong, some trial and error remains)
-

JoeJ
-
- Posts: 1489
- Joined: Tue Dec 21, 2010 6:18 pm
by Julio Jerez » Tue Apr 23, 2013 10:47 am
in the engine all joint use a coordinate frame of reference to operate. This frame is passed by the user in for of a matrix.
On that frame the first row is the principal axis, the second row is the secondary axis, the third row is the cross product of the first an second axis and the matrix position is the origin of the joint.
This matrix must be in global space.
for example the parameter value of a hinge are the origin o, the pin dir, and initial wings orientation up.
you take those values and you make a 4 x 4 matrix by setting the first row to dir, the second row to up, the third row to cross (dir, up) and the fourth row to origin.
dir and up must be perpendicular and unit vectors.
-
Julio Jerez
- Moderator

-
- Posts: 12426
- Joined: Sun Sep 14, 2003 2:18 pm
- Location: Los Angeles
-
by pr0t0z » Tue Apr 23, 2013 10:55 am
That was exactly what I was looking for, perfect.
Thanks so much for the replies, I'll try it and reply the results.
Carlos
-
pr0t0z
-
- Posts: 15
- Joined: Wed May 30, 2012 11:57 am
Return to General Discussion
Who is online
Users browsing this forum: No registered users and 0 guests