scaling with rotation

Dear all,

for some modifications and want to rotate the skull by modifiying the scaling law like this in ScalingUnivorm.any:

    AnyFolder HeadOriginal = {
      AnyVar GeomScale = (..AnthroSegmentLengths.HeadHeight / ..StandardParameters.Head.Height);
      AnyFunTransform3DLin ScaleFunction = {
        ScaleMat ={{.GeomScale,0,0},{0,.GeomScale,0},{0,0,.GeomScale}};
        Offset = {0,0,0};
      };
    };
    AnyFolder Head = {
      AnyFunTransform3DLin ScaleFunction = {
        PreTransforms = {&..HeadOriginal.ScaleFunction};
        ScaleMat = RotMat(-45 *pi/180, y) ;
        Offset = {0,0,0};
      };
    };

As the scaling function is called within the SkullSeg for the definition of all nodes and the graphics, graphics and nodes should behave like in a rigid body motion.
But although all nodes and the graphics should rotate in the same way, they do not: The nodes are rotated around another axis than the graphics. Please have a look at the attached figures. What could be the reason?

Thanks for any hint,

Thomaz

Thomas,

There is a problem in the definition of some nodes:


   AnyRefNode SternocleidomastoidNode = {sRel = .Scale({-0.034+0.018+0.01,-0.025+0.005,0.074})*.Mirror;};

Mirroring has to happen before scaling. This sequence causes some nodes not to rotate visually. The fix would be (will need to scroll):


   AnyRefNode SternocleidomastoidNode = {sRel = .Scale({-0.034+0.018+0.01,-0.025+0.005,0.074}[b]*.Mirror)[/b];};

Was the problem in the Sternocleidomastoid and a couple of more muscles? Or is it something that you’re implementing yourself?

Regards,
Pavel

Hi Pavel,

thanks for the speedy reply. In my case there is no Mirror included. I use AB5.3, AMMRV1.5, StandingModel, SkullSeg in SegmentsThoraxWithoutNeck.any, e. g.

    AnyRefNode LumpedHyoidT1C0NodeR = {sRel = .Scale({0.006+0.018,-0.006+0.005,0.018});AnyDrawNode drw ={};};
    AnyRefNode LumpedHyoidT1C0NodeL = {sRel = {.LumpedHyoidT1C0NodeR.sRel[0],.LumpedHyoidT1C0NodeR.sRel[1],.LumpedHyoidT1C0NodeR.sRel[2]*-1};AnyDrawNode drw ={};};

The second node has just the z coordinate negative. This should be all right, shouldn’t it?

I assume that something is wrong with my modified scaling law. When i transform (rotate) around x, the nodes rotate around z (rotation on midsagittal plane). The skull anysurf however rotates around x (lateral bending to the right or left).

Therefore there are two points which i do not understand:
1.) Why is the anysurf scaled differently than the nodes although they are scaled by the same scaling function,
2.) why do the nodes sometimes not move as a rigid body (there distance before and after scaling is different). They are only like a rigid body when rotating around x.

Could you please exchange the original scaling law with my modified one to see what i mean?

Thanks and kind regards,

Thomaz

Thomas,

I think this is the same problem. Try this:

    AnyRefNode LumpedHyoidT1C0NodeR = {sRel = .Scale({0.006+0.018,-0.006+0.005,0.018});AnyDrawNode drw ={};};

 AnyRefNode LumpedHyoidT1C0NodeL = {sRel = .Scale({0.006+0.018,-0.006+0.005,-1*0.018});AnyDrawNode drw ={};};


It can also be reorganized a little different:

    
AnyVec3 LumpedHyoidT1C0NoderVec = {0.006+0.018,-0.006+0.005,0.018};
AnyRefNode LumpedHyoidT1C0NodeR = {sRel = .Scale(.LumpedHyoidT1C0NoderVec);AnyDrawNode drw ={};};

 AnyRefNode LumpedHyoidT1C0NodeL = {sRel = .Scale(.LumpedHyoidT1C0NoderVec*{{1,0,0},{0,1,0},{0,0,-1}});AnyDrawNode drw ={};};


But the problem is the same that the mirroring happen after you scaled.
I actually found the problem by using your scaling law. I think it may be the same for a few more points - it’s not that frequently used.

Regards,
Pavel

aaah, yes, of course. Thanks! :slight_smile:
But this only explains why the nodes do not behave like a rigid body.
For rotation around x or z the DrwSurf1 from SkullSeg still performs lateral bending while the nodes do a flexion-extension and vice versa. Only for a rotation around y, DrwSurf1 and nodes behave in the same way.
Any ideas on that?

Thomas,

That’s also an interesting problem. There was a special rotation that was accounted for rotating the STL of the skull, which had 90 degrees of rotations. ARel = {{0,0,-1}, {0,1,0},{1,0,0}}. If we comment this one out - it behaves like it should, but we also need to change the stl of the skull. I have done and it works perfect. What i did i applied this rotation matrix to the STL and this way i could eliminate rotation from the code.

    AnyRefNode drworientation = {
      sRel = .Scale({0.0, 0.0, 0.0});
      //ARel = {{0, 0, -1}, {0, 1, 0}, {1, 0, 0}};
      
      AnyDrawSurf DrwSurf1 = {
        FileName = "./BonesSpine/SkullUpdated";
        RGB = ....ColorRef.Segments;
        ScaleXYZ = {1, 1, 1};
        AnyFunTransform3D &Scale =..Scale; 
        Opacity = Main.DrawSettings.BonesOpacity.Skull;
      };
    };  

But this was only a visual problem.

Regards,
Pavel

Hi Pavel,

i understand now. Thanks.

How did you transform the STL? Can this be done with a command in the STL code or in the anysurf file?

Thanks for your help and kind regards,

Thomaz

I rotated in Meshlab an exported STL, but this can also be done in AnyBody.


// not checked code
AnyFixedRefFrame fr  = {
 AnyDrawSurf SkullNew = {
   FileName="<ANYBODY_PATH_BODY>\Trunk\BonesSpine\Skull";
   AnyFunTransform3DLin tr = {
      ScaleMat={{0,0,-1},{0,1,0},{1,0,0}};
      Offset ={0,0,0};
   };
 };
};

And then use a class-operation and export in global - i think that will do the trick. I just used whatever came quickest to my mind :slight_smile:

P.

looks good, nice.

Thanks again and nice weekend,

Thomaz