Rotation matrix / RefFrame.Axes

Hi,

is there an easy way to get the 3 angles from the rotation matrices? Maybe you already have a matlab script ready? If not, in which oder do you multiply the matrices (e.g. x,y,z?)?

Best regards,
Patrick

What kind of AnyKinRotationalType is used in your model and how is the rotation sequence (zyx, xyz, …)?

Hi Patrick,

If you use AnyKinRotational, you can decompose it into 3 angles using RotAxesAngles type, which you may already know.

But if you only have a 3 by 3 matrix, we don’t have a function to decompose it.

Best regards,
Moonki

Thanks for you answers. I believe I already have the 3 single angles like you suggested, Moonki. Just didn’t notice it, sorry =/

Unfortunately I’m stuck here. I want to get the orientation of the AnyRefNode HipJoint compared to the local coordinate system of the femur segment. In the Seg.any (MoCapModel AMMR v1.6) the orientation of HipJoint Node is defined as:

ARel = RotMat(sRel, .Scale(.StdPar.KneeJoint), sRel+ .KneeJoint.ARel'[2])*RotMat(-pi/2,x)*RotMat(pi/2,z);

So the 2 second rotations are easy to understand, but the first one is incomprehensible to me =)

RotMat(sRel, .Scale(.StdPar.KneeJoint), sRel+ .KneeJoint.ARel'[2])

Here the AnyFunRotMat for 3 Points is used, whose definition can be found in the Reference Manual:

RotMat3Points [i]Rotational tranformation matrix for a coordinate system defined by three points. The first point is the origin of the system; the second gives the direction of the first (x) axis. Together all three points must span a plane which will be the plane of the first (x) and the second (y) axes, having the third (z) axis as normal.

[/i]But this definition lack the description of third parameter and also in my case the three parameters are a={0,0,0}, b={0.04130499, -0.4211364, 0.01401817} and c={-0.5267189, -0.113155, 0.8424744}. And as b and c are not perpendicular I do not understand how they could be an x and y axis.

Well, now that I write this I see that b and c span a plane and that you could calculate a vector that is perpendicular on b (1st axis) and the plane’s normal (2nd axis) as a third axis. But still I don’t know in which direction the the y and z axis will point. What am I missing?

I would be very thankful for any suggestions or a description of the RotMat33 function.

Hey Patrick,

The first parameter specifies the origin of the reference frame, the second parameter specifies the direction of the x-axis and the third parameter specifies the direction of the y-axis. The x-axis comes directly as the unit vector between the origin and the second point. The y-axis is constructed to be orthogonal to the x-axis and pointing towards the third point. This is basically accomplished with an orthogonal projection of the second point. The z-axis is constructed as the cross product between the x- and y-axis.

I hope that helps.

Best regards
Michael Skipper Andersen
The AnyBody Research Group
Aalborg University

Thanks, now I understand how this coordinate system is created. But this seems to be some kind of Wahba’s problem and I wouldn’t know how to get the rotation angles.

So again, what I want to know is how the HipJoint-RefNode is oriented in regards to the local coordinate system of the femur.

For the 1.6 MoCapModel the AnyRefNode is:
Main.Studies.HumanModel.BodyModel.Right.Leg.Seg.Thigh.HipJoint
Is it correct, that ARel is the matrix for the rotation of the HipJoint-RefNode against the coordinate system of the femur?

Hi Patrick,

It seems that you want to get the rotation angles of ‘Thigh.HipJoint’ AnyRefNode with respect to the Thigh segment coordinate system.

And as we know, we could see the ARel matrix of ‘Thigh.HipJoint’ AnyRefNode but ARel matrix can’t tell the rotation angles because it will be different according to the sequence of the rotation order.

The easiest way to know the rotation angles is using AnyKinRotational class object. And you can even define your own AnyKinRotational measure between the reference nodes in the same segment.

So all you need to do is using this kind of code:

        AnyKinRotational HipJointNodeOrientationAngles = 
        {
          AnyRefFrame& base = Main.Studies.HumanModel.BodyModel.Right.Leg.Seg.Thigh;
          AnyRefFrame& target = Main.Studies.HumanModel.BodyModel.Right.Leg.Seg.Thigh.HipJoint;
          Type = RotAxesAngles;
          Axis1 = z;
          Axis2 = y;
          Axis3 = x;
        };

Of course you have to modify Axis1, Axis2, Axis3 if you want to change the order of the rotations.

I hope this may help you.

Best regards,
Moonki

Hi Moonki,

thanks for your post. I will implement this code in future models!
I believe I found a solution (or workaround) by myself. I was interested in getting the global orientation of the geometries and it was possible to find those by creating a second femur and moving this into the global coordinate system =)

Regards

Patrick