Page 1 of 1

How do I set the transform of geometry within body?

Posted: Tue Mar 02, 2021 1:26 pm
by uqrwilk5
Hello,

Could you please tell me how to set the position (transform) of multiple geometry files within a body using the MATLAB API. I.e., I would like to set the transform of 'cerv1.vtp' mesh as [0 0 0 0.0216 0.1179 0].

Code: Select all

head = Body('head', headMass, Vec3(0), Inertia(1));
head.attachGeometry(Mesh('skull.vtp'));
head.attachGeometry(Mesh('jaw.vtp'));
head.attachGeometry(Mesh('cerv1.vtp'));
head.attachGeometry(Mesh('cerv2.vtp'));
head.attachGeometry(Mesh('cerv3.vtp'));
head.attachGeometry(Mesh('cerv4.vtp'));
head.attachGeometry(Mesh('cerv5.vtp'));
head.attachGeometry(Mesh('cerv6.vtp'));
head.attachGeometry(Mesh('cerv7.vtp'));
model.addBody(head);
Any help is appreciated.

Thanks in advance,
Ross

Re: How do I set the transform of geometry within body?

Posted: Wed Mar 03, 2021 3:06 am
by mn13rt
Geometry is just for visualisation so if you did add all the geometry to the same body it would be easier to merge them separately into the same .vtp or .stl file with the transformations you want, then add a single .vtp to the body.

If you are wanting movement between them and/or want to add them individually anyway, each geometry file would need its own body. Then when setting up the joints between bodies you can set the relative transformations.

Best wishes,
Rory

Re: How do I set the transform of geometry within body?

Posted: Thu Mar 04, 2021 2:47 pm
by aymanh
Thanks Rory,

The attachGeometry call assumes that there's no offset (Geometry/Mesh is attached to the specific Frame directly). If an offset is needed, you can create an OffsetFrame with a fixed offset from the Body and then call attachGeometry on this OffsetFrame. The offset is specified by a SimTK::Transform which can be made up from Translation and Rotation.

Hope this helps,
-Ayman