questions about AnyVec3

Hello,

In the GaitLowerExtremity model I have to make a reference frame trough the thigh segment via the bony landmarks in the epicondylus to the hip joint. I made a vector through those points but I have still some questions. What exactly does the AnyVec3 do and How can I get exactly a reference frame trough those two points?

Best regards,

Hans

Hi Hans,

Please take a look at the RotMat(AnyVec3 Pnt1, AnyVec3 Pnt2, AnyVec3 Pnt3) function.

RotMat3Points
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.

And define your reference frame by constructing Origin and Axes accordingly:

  AnyFixedRefFrame <ObjectName> = 
  {
    //Origin = {0, 0, 0};
    //Axes = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
  };

Regards,
Pavel

Hello,

Thanks for your reply. But I still have one remaining question. If you have two nodes in a segment. How can you get the original point of a node in this frame. Because the sRel is in local coordinates and the FixedRefFrame in global coordinates. And I have generated this vector [SIZE=3]
[SIZE=2]AnyVec3[/SIZE][/SIZE] ShankVec = -IntraTibialEpicondyle.sRel-IntraMallolar.sRel ;

How can I get the Axes trought that vector in the AnyFixedRefFrame class?

Best Regards,

Hans

Hi Hans,

These nodes would have .r and .sRel members, where .sRel as you said local, .r is the global one. You can also define your new reference node within the same segment using relative terms:

AnyRefNode <ObjectName> = 
{
  //sRel = {0, 0, 0};
  //ARel = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
};

where you can work in local (sRel/ARel) terms instead of global terms (origin/axes). Something like:


AnyRefNode node_orig = {sRel={0.1, 0.2, 0.3};};
...
AnyRefNode ShankRefFrame ={
  sRel=.node_orig.sRel;
  ARel=RotMat(.node_orig.sRel, .node_target.sRel, .node_for_restaxes.sRel);
};

Regards,
Pavel

Hello,

I have made this code now:

[SIZE=3][SIZE=2]AnyRefNode[/SIZE][/SIZE] ShankRefFrame ={
sRel=.IntraMallolar.sRel;
ARel=RotMat(.IntraMallolar.sRel ,.IntraTibialEpicondyle.sRel,.KneeJoint.sRel )
[SIZE=2]};[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2]But the rotations aren’t what I need. The Y direction is the forward direction the X-axis is the vertical direction and the Z-axis is the lateral direction. The rotations must be oriented as follows: The Y-Axis need to go from the Intramallolar to the IntraTIbialEpicondyle. The X-axis need to have a forward direction and the Z-axis needs to be the lateral directions. How can I achieve those rotations?[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2]Best regards,[/SIZE]
[SIZE=2][/SIZE]
[SIZE=2]Hans

[/SIZE]

Hi Hans,

Construct a node on the needed X axis and use it as a second parameter. Use .IntraTibialEpicondyle.sRel as a third parameter to have Y as vertical axis, or construct another node on perpendicular plane using cross product function: cross(AnyVec3 u, AnyVec3 v), and use it as a second parameter - then the Z axis will be vertical.

Or an easy solution: multiply by RotMat(90pi/180, z) or RotMat(90pi/180, x) or RotMat(90*pi/180, y) needed number of times.

Hope this helps.

Pavel

Hello,

Thank you for your reply and this helps me indeed a lot but I have one remaining thing left. In the right leg the X-Axis is indeed forward now but in the left leg the X-axis is more lateral oriented. How can I fix is that in both legs the X axis turns forward?

Best regards,

Hans

Hi Hans,

You can always define a second ref. frame (left-leg-specific) and if you want to use the same name later on you can define a reference to the object, like:

Main.HumanBody.Left.Leg = {AnyRefNode rf_l = ...};
Main.HumanBody.Right.Leg = {AnyRefNode rf_r = ...};
...
Main.HumanBody.Left.Leg = {AnyRefNode &rf = rf_l};
Main.HumanBody.Right.Leg = {AnyRefNode &rf = rf_r};

Is that what you asked?

Regards,
Pavel

Hello,

Where can I put this code because if I’m doing this code:

within the shank:
Main.HumanBody.Left.LegShank ={AnyRefNode leftdummyNode={
sRel={0,0,0};
};
};
I will get this error:
[SIZE=1][SIZE=1]Loading Main : “H:\J.H.Schreuders\AMMRV1.3\Application\Examples\GaitLowerExtremity\GaitLowerExtremity.main.any”
Scanning…
Parsing…
[COLOR=#0000ff][SIZE=1][COLOR=#0000ff]ERROR(SCR.PRS1)[/SIZE] : [SIZE=1]H:/J.H.Schreuders/A…3/Body/A…n/LegTD/Seg.any[/SIZE] : ‘leftdummyNode’ : Object already declared at :
[SIZE=1]H:\J.H.Schreuders\AMMRV1.3\Body\AAUHuman\LegTD\Seg.any(844)[/SIZE] : ‘leftdummyNode’
Model loading skipped

Best regards,

Hans
[/COLOR][/SIZE][/COLOR][/SIZE]

Please reread the error message - it normally explains what the problem is. It looks like you defined this dummy node in Seg.any as well as in the Main file, is that so? It should not be either in Seg.any or in the Main file. Please note that the same Seg.any is used for the right and left legs - therefore this node will be copied, however, if you create it like i suggested then it won’t be duplicated.
Regarding location: you can add these lines in the Main file or wherever you want as long you make correct paths.
By the way - “Main.HumanBody.” path i took from the top of my head - please use correct paths and real objects, e.g.: Main.Studies.HumanModel.BodyModel.Right.Leg.Seg.Shank - you can go to the model view and right click on any object - it will suggest to ‘copy complete name’.

Hello,

I have constructed this code to have a certian rotation:
[SIZE=1]Main.Studies.KinematicStudyForParameterIdentification.HumanModel.BodyModel.Right.Leg.Seg.Shank=
{
[/SIZE]AnyRefNode IntraMallolarRight ={
sRel={0.07232129, -0.7544863, 0.02333341};
AnyDrawNode drwDymmy =
{
Visible = On;
//Opacity = 1;
RGB = {0, 0.0, 0.0};
ScaleXYZ = {0.025, 0.025, 0.025};
//Transparency = 1;
}; };
AnyRefNode IntraTibialEpicondyleRight ={
sRel={0.05196971, -0.445903, 0.01255952};
AnyDrawNode drwDymmy =
{
Visible = On;
//Opacity = 1;
RGB = {0.5, 0.0, 0.0};
ScaleXYZ = {0.025, 0.025, 0.025};
//Transparency = 1;
}; };

AnyRefNode DummyNodeRight =
{sRel={0.22660646, -0.741364079 , 0.106};
AnyDrawNode drwDymmy =
{
Visible = On;
//Opacity = 1;
RGB = {0.5, 0.5, 0.0};
ScaleXYZ = {0.025, 0.025, 0.025};
//Transparency = 1;
}; };
AnyRefNode ShankRefFrameRight ={
sRel=.IntraMallolarRight.sRel;
//ARel=RotMat(90*pi/180, x)RotMat(90pi/180, z)RotMat(90pi/180, y);
ARel=RotMat(.IntraMallolarRight.sRel,.DummyNodeRight.sRel ,.IntraTibialEpicondyleRight.sRel );

My question is how can I get the vertical axis through the intratibialEpicondylle

Best regards,

Hans

Hello,

I posted yesterday a question about a specific orientation of a local reference fram. I tried to calculated the point by myself but after loading the initial conditions it doesn’t have the appropiate orientation. What can I do to achieve the appropiate orientation?

Best regards,

Hans

Hi,

When using the RotMat function with three point the Y axis will almost never go exactly through the third point. Not unless the three points are perfectly placed and forming a 90 deg angle.

So the most important direction must be driven by the second point in the RotMat. I understand that in your case it is the intratibialEpicondylle. Your ARel is then:
ARel=RotMat(.IntraMallolarRight.sRel, ,.IntraTibialEpicondyleRight.sRel, .DummyNodeRig ht.sRel );

Now you have the X axis going exactly through the intratibialEpicondylle. If you want it to be Y or Z instead you just add one or more RotMat to the ARel with 90 deg rotations to switch around the axis. Something like this:
ARel=RotMat(.IntraMallolarRight.sRel, ,.IntraTibialEpicondyleRight.sRel, .DummyNodeRig ht.sRel )*RotMat(pi/2,z)*RotMat(…);

Best regards, Sylvain.