Page 1 of 1

How to edit DisplayGeometry transform in Matlab

Posted: Mon Jun 26, 2017 1:32 am
by pittpanther13
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>

Re: How to edit DisplayGeometry transform in Matlab

Posted: Mon Jun 26, 2017 7:58 pm
by tkuchida
I have tried getting and setting the values using the GeometrySet and/or DisplayGeometry classes but with no success.
DisplayGeometry::setTransform() (https://simtk.org/api_docs/opensim/api_ ... 85f8966014) doesn't work?

Re: How to edit DisplayGeometry transform in Matlab

Posted: Thu Jun 29, 2017 7:29 am
by pittpanther13
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.

Re: How to edit DisplayGeometry transform in Matlab

Posted: Fri Jun 30, 2017 2:54 am
by tkuchida
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.