Forums Anyscript.org  

Go Back   Forums Anyscript.org > General Forum > AnyBody Modeling System

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 05-08-2014, 06:29 PM
thomaz thomaz is offline
Senior Member
 
Join Date: May 2009
Posts: 173
Default scaling with rotation

Dear all,

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


Code:
    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
Attached Images
File Type: jpg notrotated.jpg (16.3 KB, 5 views)
File Type: jpg rotated.jpg (15.1 KB, 6 views)
Reply With Quote
  #2  
Old 05-08-2014, 06:59 PM
pgalibarov's Avatar
pgalibarov pgalibarov is offline
Senior Member
 
Join Date: Oct 2010
Posts: 960
Default

Thomas,

There is a problem in the definition of some nodes:
Code:
   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):
Code:
   AnyRefNode SternocleidomastoidNode = {sRel = .Scale({-0.034+0.018+0.01,-0.025+0.005,0.074}*.Mirror);};
Was the problem in the Sternocleidomastoid and a couple of more muscles? Or is it something that you're implementing yourself?

Regards,
Pavel
Reply With Quote
  #3  
Old 05-09-2014, 10:32 AM
thomaz thomaz is offline
Senior Member
 
Join Date: May 2009
Posts: 173
Default

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.

Code:
    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

Last edited by thomaz; 05-09-2014 at 11:10 AM. Reason: additional information
Reply With Quote
  #4  
Old 05-09-2014, 03:47 PM
pgalibarov's Avatar
pgalibarov pgalibarov is offline
Senior Member
 
Join Date: Oct 2010
Posts: 960
Default

Thomas,

I think this is the same problem. Try this:

Code:
    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:

Code:
    
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
Reply With Quote
  #5  
Old 05-09-2014, 04:34 PM
thomaz thomaz is offline
Senior Member
 
Join Date: May 2009
Posts: 173
Default

aaah, yes, of course. Thanks!
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?
Reply With Quote
  #6  
Old 05-09-2014, 05:08 PM
pgalibarov's Avatar
pgalibarov pgalibarov is offline
Senior Member
 
Join Date: Oct 2010
Posts: 960
Default

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.

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
Reply With Quote
  #7  
Old 05-09-2014, 05:15 PM
thomaz thomaz is offline
Senior Member
 
Join Date: May 2009
Posts: 173
Default

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
Reply With Quote
  #8  
Old 05-09-2014, 05:19 PM
pgalibarov's Avatar
pgalibarov pgalibarov is offline
Senior Member
 
Join Date: Oct 2010
Posts: 960
Default

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

Code:
// 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

P.
Reply With Quote
  #9  
Old 05-09-2014, 05:21 PM
thomaz thomaz is offline
Senior Member
 
Join Date: May 2009
Posts: 173
Default

looks good, nice.

Thanks again and nice weekend,

Thomaz
Reply With Quote
Reply

Tags
rigid body, rotation, scaling, transformation

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 09:25 PM.