# Making a local rotation parallel to the global refframe

Hello,

In the feet I made this rotation:
[SIZE=3]AnyFloat[/SIZE] p1=-14.282pi/180;
[SIZE=3]AnyFloat[/SIZE] p2= 2.141
pi/180;
[SIZE=3]AnyFloat[/SIZE] p3=5.09937933*pi/180;
[SIZE=3]AnyRefNode[/SIZE] ISBNodeAnalyse={
[SIZE=3]AnyMat33[/SIZE] Rotation = RotMat(.HeelNodeStandard, .BigToeNodeStandard,.SubTalarJointStandard)*RotMat(.p1,x)*RotMat(.p2 ,z)*RotMat(.p3,y);
ARel=Rotation;
sRel=.HeelNode.sRel;
[SIZE=3]AnyDrawRefFrame[/SIZE] drw ={
Visible = On;
ScaleXYZ={0.5,0.5,0.5};
RGB={.1,0.6,0.3};};};
Now I want use the variables p1, p2 and p3 in such a way that the Axes of this node will be {1,0,0},{0,0,1},{0,-1,0}; Which method is appropiate for that?

Best regards,

Hans

Hi Hans,

If matrix A0 is Axes0 of the segment, where the node is defined. A1 is the ARel that you defined in the node. Then Axes (of the node) = A0*A1.

In order to set Axes to be B (your matrix), you need to do the following:
rotation will consist of several steps -> Axes=B= (A0*(A1*A1.T)*A0.T)*B, where .T means transposition, () gives identity matrix => ARel = .A0’*B.

Hope that this is what you asked for.

Regards,
Pavel

Hello,

Thank you for your reply, but I have one remaining question. How can I formulate this in the node?

Best regards,

Hans

As I can see from the title of your question, parent segment/ref.frame is the global reference frame, then:

AnyRefNode ISBNodeAnalyse={
AnyMat33 axesnew = {{1,0,0},{0,0,1},{0,-1,0}};
ARel=axesnew;

OR

ARel = Rotation*Rotation’*axesnew;
};

Or if you have a parent segment, then:

ARel = .parentsegment.Axes0’*axesnew; (please note that if you have many nested segments, then you will have to add those too)

Hello,

This is not what I want to achieve The local reference frame needs to be parallel orientated to the goblal reference frame so that the Y-axis will be exactly vertical and X- axis exactly horizontal. With the solutions you present ARel will be the identity matrix but I need to have the ISBNodeAnalyse.Axes to be the identity matrix.

best regards,

Hans

No, it won’t. It will be ‘axesnew’, which contains the rotation that you requested in your original question. Identity does not rotate anything.

If you create this node detached from any segments, but connected to a global ref. frame, then ParentSegment.Axes0 = I.

Hello,

Thank you for your reply but I cannot write Axes by myself because it’s a dienied acces member so where do I have to define this code?

Best regards,

Hans

Hi Hans,

You cannot assign it and I wrote how it is being calculated a couple of times. YourNode.Axes is the rotation matrix in global ref. frame (computed automatically), whereas ARel is the rotation matrix in the local ref. frame that you can enter. To go from local to global you multiply all nested rotations.

So if you have a segment A with rotations B, nested node C, with ARel D:
AnySeg A = {Axes0 = B;
AnyRefNode C = {ARel=D;};
};

Then A.C.Axes = BD OR A.C.Axes=A.Axes0C.ARel;
If you want A.C.Axes to be matrix F => you rotate everything to the global ref. frame to make the rotation matrix Identity first, and then multiply by F. Then it becomes:
A.C.Axes = (B*(D*D’)*B’)F=((I))F=F
So in the code above it will be: ARel = D
D’
.Axes0’*F. If your Axes0 is identity you will receive what i wrote above several times.

Please try to create a simple model, enter simple matrices, and understand what Axes object is and how it is computed. I suggest you start with a small example as in my answer. When you load your model these objects are accessible to check in the model tree view. You can see the actual values and play with the numbers.

If you do not have clear understanding of these basics - you may make mistakes in your model. So i recommend you to spend a little bit of time on this problem.

Best regards,
Pavel

Hello,

I tried it with a simple model and this will indeed give me the solution I want. I will do it now in my model too.

Best regards,

Hans

Hello,

The last status of the problem: when I make the Axes0 of the feet equal to the value of Foot.Axes then the matrix in the ISBNodeAnalyse is an entity matrix both when the model is loading and when the initial conditions are used. This is also the case for the pelvis and thorax. Only in the left foot Axes = {{0.7603833, -0.2863198, -0.5829564}, {-0.5318971, -0.7895995, -0.3059708}, {-0.3726965, 0.542728, -0.752691}} and in the right foot {{1, -6.025384e-008, -4.112028e-008}, {-4.804978e-008, 7.611931e-007, -1}, {3.93603e-008, 1, 7.051857e-007}} which I consider as an entity matrix. Why isn"t the axes in the left foot an entity matrix as well?

Best regards,

Hans

Hi Hans,

Please be more specific about what objects you are looking at - then I may help with specific locations of object definitions.

It is non-identity because some Axes0 and r0 are prescribed in the initial conditions, which will be used as an initial guess to kinematic solver:
http://www.anybodytech.com/693.0.html

To make it identity you will have to use what i suggested before (F=I), but taking into account dynamic changes and using segmental Axes0, e.g. using the A.Axes0’ as a multiplier. Do exactly the same thing that worked for you in the simple example.

Could you please be more specific on what you are trying to achieve? (beyond making 2 reference frames parallel). Maybe this can be done easier.

Regards,
Pavel

Hello,

What I try to achieve is the following: When my model will be set to the dataset I load in the local reference frame must be parallel to the global reference frame in the thorax, pelvis and feet. This is necesary because I have to compare the GaitLowerExtremity model with another independent softwaretool which has that assumtion.

Best regards,

Hand

still not specific - what kind of entities are you trying to compare? are you looking at the joint angles? forces? are you driving AnyBody model using data from another software? etc.

Unfortunately you are not providing us with information that can be used to help. I cannot clearly see why the suggested solution suggested does not work for you.

Pavel

Hello,

I need to compare the following entities: segment positions first, then joint angles and later on also joint forces and joint moments plus muscle forces. The entitiy matrix in axes must be an entity matrix if the initial conditions are used and not if the model is loaded.

I hope this make it more clear to you.

Best regards,

Hans

Hello,

The last status of the problem: when I make the Axes0 of the feet equal to the value of Foot.Axes then the matrix in the ISBNodeAnalyse is an entity matrix both when the model is loading and when the initial conditions are used. This is also the case for the pelvis and thorax.

Best regards,

Hans

Hans,

In order to achieve what you want, namely measure your angles and displacements as compared to the global reference frame, it is easier to construct proper measures such as AnyKinRotational and AnyKinLinear and use relevant components.
__ Tutorials: Kinematic measures__
Segmental members may give you information about positioning in the global reference frame too. For example, accessing .r member of AnySeg will give you global position of the segment.

However, rotation may require a bit of processing, such as decomposing rotational matrices into angles - much easier for you to go with AnyKinRotational. Something like:

``````AnyKinRotational myrotmeasure =
{
Type = RotAxesAngles;
Axis1 = z;
//Axis2 = y;
//Axis3 = x;
AnyRefFrame &segrefframe = ..mySeg;
AnyRefFrame &globrefframe = Main.GlobalRefFrame;
};

``````

Where myrotmeasure.Pos will be the rotation about global Z axis.

Similarly, AnyForce contains members in global and local reference frames - so you may just use them.
__Tutorials: Forces __

Please go through the tutorials again - I think there is just enough information to solve your task.

Best regards,
Pavel

Hello,

[SIZE=3]AnyKinRotational[/SIZE] RotmeasureFootRefFrame =
{
Type = RotAxesAngles;
Axis1 = z;
[SIZE=3]// Axis2 = y;
// Axis3 = z;
[/SIZE][SIZE=3]//AngVelOnOff = Off;
[/SIZE][SIZE=3]//AngVelGlobal = Off;
[/SIZE][SIZE=3]AnyRefFrame[/SIZE] &FootRefFrame = Main.Studies.KinematicStudyForParameterIdentification.HumanModel.BodyModel.Right.Leg.Seg.Foot.ISBNodeAnalyse;
[SIZE=3]AnyRefFrame[/SIZE] &GlobalRefFrame = Main.Studies.KinematicStudyForParameterIdentification.EnvironmentModel.GlobalRef;

};

Will this measure the displacements in such a way that I can formulate the proper rotations?

Best regards,

Hans

Hello,

I used this to make a Rotation where axes in the initial conditions is an identity matrix:
[SIZE=3]AnyFloat[/SIZE] p1=-0.2489909;
[SIZE=3]AnyFloat[/SIZE] p2= 0.03717305;
[SIZE=3]AnyFloat[/SIZE] p3= 0.08901289;
[SIZE=3]AnyRefNode[/SIZE] ISBNodeAnalyse={

ARel=Rotation;
[SIZE=3]AnyMat33[/SIZE] Rotation = RotMat(.HeelNodeStandard, .BigToeNodeStandard,.SubTalarJointStandard)*RotMat(.p1,x)*RotMat(.p2 ,z)*RotMat(.p3,y);

sRel=.HeelNode.sRel;[SIZE=3] [/SIZE]};

My question is : Is it possible to replaces the values of p1, p2 and p3 with an expression that it will use the values of the AnyKinRotational instead of a constant value?

Best regards,

Hans

Hans,

RotmeasureFootRefFrame.Pos will correspond to the p2 value and you can use it for rotation (if p2 is the angle about global Z axis in a single point of time).

Regards,
Pavel

Hello,

If i use this as expression:
[SIZE=3]AnyFloat [/SIZE]p1=Main.Studies.MotionOptimization.RotmeasureFootRefFrame.Pos;[SIZE=3]
[/SIZE][SIZE=3]AnyFloat[/SIZE] p2=Main.Studies.MotionOptimization.RotmeasureFootRefFrame.Pos;[SIZE=3] [/SIZE][SIZE=3]AnyFloat[/SIZE] p3= Main.Studies.MotionOptimization.RotmeasureFootRefFrame.Pos;

I got this error message:

Scanning…
Parsing…
Constructing model tree…