Provide easy-to-use, extensible software for modeling, simulating, controlling, and analyzing the neuromusculoskeletal system.
-
Ryan Byrne
- Posts: 28
- Joined: Thu Jan 22, 2015 8:33 am
Post
by Ryan Byrne » Mon Jun 26, 2017 1:32 am
Hi all,
I am relatively new to OpenSim Scripting in Matlab and am having a trouble figuring out how to edit the <transform> array - within the <GeometrySet> class shown at the bottom - via Matlab. I have tried getting and setting the values using the GeometrySet and/or DisplayGeometry classes but with no success. My most recent attempt was using the member function from the API
Code: Select all
getRotationsAndTranslationsAsArray6 (double aArray[]) const
within the DisplayGeometry class but also wasn't successful. Any help or pointers on which methods/classes/syntax to use to do this would be much appreciated.
Code: Select all
<Body name="lumbar5">
<VisibleObject>
<GeometrySet>
<objects>
<DisplayGeometry>
<geometry_file>newlumbar5.vtp</geometry_file>
<color> 1 1 1</color>
<texture_file />
<transform> 0 0 0 0 0 0</transform>
<scale_factors> 1 1 1</scale_factors>
<display_preference>4</display_preference>
<opacity>1</opacity>
</DisplayGeometry>
</objects>
<groups />
</GeometrySet>
-
Ryan Byrne
- Posts: 28
- Joined: Thu Jan 22, 2015 8:33 am
Post
by Ryan Byrne » Thu Jun 29, 2017 7:29 am
Thank you. I believe this is the correct function, but due to my unfamiliarity with the syntax I am not sure exactly what (const SimTK::Transform & aTransform) is asking for. For most classes I have been able to sort through and figure out the required inputs but not so much for this one.
-
Thomas Uchida
- Posts: 1787
- Joined: Wed May 16, 2012 11:40 am
Post
by Thomas Uchida » Fri Jun 30, 2017 2:54 am
The documentation for the
SimTK::Transform class can be found in the Simbody API documentation here:
https://simtk.org/api_docs/simbody/3.5/ ... orm__.html. Here's an example script:
Code: Select all
import org.opensim.modeling.*;
model = Model('arm26.osim');
body = model.getBodySet().get('r_humerus');
geom = body.getDisplayer().getGeometrySet().get(0);
geom.getTransform().T() %translation
geom.getTransform().R() %rotation
newTranslation = Vec3(1,2,3);
newTransform = Transform(newTranslation);
geom.setTransform(newTransform);
geom.getTransform().T()
Please see the link above for other ways of constructing and modifying Transforms.