Page 1 of 1

Axes provided to the joint transform are not perpendicular

Posted: Thu May 19, 2011 2:23 pm
by m.starkov
Hi,

I'm getting "The axes provided to the joint transform are not perpendicular. Ensure that the specified axes form a valid constraint." when trying to create a SwivelHingeJoint.
As I understand axis determine process is fully incapsulated inside the SwivelHingeJoint constructor.
Thus I can't see any workaround here.
I have tried to swap bodies in the call with no effect.

body1 {X:4 Y:10 Z:5}
body2 {X:4 Y:10.2 Z:7}
anchor {X:4 Y:11.975 Z:7}
axis: {X:0 Y:-1 Z:0}

So offsets will be like : {X:0 Y:1.975 Z:2}, and {X:0 Y:-1.775 Z:0}

And we have the following:
SwivelHingeJoint -> TwistLimit -> SetupJointTransforms
Call SetupJointTransforms( {X:0 Y:1.975 Z:2}, {X:0 Y:-1.775 Z:0} )
{
worldXAxis found as {X:-1 Y:0 Z:0}
with quaternion {X:-0.7115399 Y:0.7026458 Z:0 W:0}
worldXAxis become {X:-0.01257783 Y:0.999921 Z:0}
(the quaternion is retrieved by the following:
Toolbox.GetQuaternionBetweenNormalizedVectors( {X:0 Y:1.975 Z:2}, {X:0 Y:-1.775 Z:0}, out rotation);
Vectors are actually not normalized - is it fine?
Inside of GetQuaternionBetweenNormalizedVectors there is note:
//For non-normal vectors, the multiplying the axes length squared would be necessary:
//float w = dot + (float)Math.Sqrt(v1.LengthSquared() * v2.LengthSquared());
But in spite of not normalized vectors "length squared" is commented out.
May be it is not yet completed function?
)

Call SetWorldAxes ( {X:0 Y:-1.775 Z:0}, {X:-0.01257783 Y:0.999921 Z:0} )
And here SetWorldAxes says that its arguments are not perpendicular...
}

It seems like axes Normalization is forgotten before the call to GetQuaternionBetweenNormalizedVectors.

Could one please advise?

P.S. I've tried to put normalization by myself just to check if it's so easy to fix it however error remained the same and moreover from that moment I can't see debug inside the BEPU code now. Even after returning previous library back... I'm confused about that.

Re: Axes provided to the joint transform are not perpendicul

Posted: Thu May 19, 2011 11:06 pm
by Norbo
There were indeed missing normalizations in both the TwistLimit and TwistMotor; thanks for the report.

I also changed something in the SwivelHingeAngularJoint which allows it to cope gracefully with degenerate configurations (it would previously cause a NaN explosion). You can grab the latest version here: http://bepuphysics.codeplex.com/SourceC ... evelopment

Re: Axes provided to the joint transform are not perpendicul

Posted: Fri May 20, 2011 4:58 pm
by m.starkov
It seems the issue is gone.

Thank you so much!