# Geometry3D objects as functions of parameters

I want to make a simulation of a rigid body with mathematica, but I want to use a Geometry3D object instead of a Graphics3D primitive.

Mainly I don't know how to rotate the 3D model, I know how to do it with graphs through for example:

GeometricTransformation[ring3,EulerMatrix[{alpha, beta, gamma}, {1, 2, 3}]]


Is there any way to rotate and translate the 3D model in such a way?

• Look up TransformedRegion Oct 24 '20 at 1:34
• I find GeometricTransfomation following your suggestion, I think it will do it, thank you! Oct 24 '20 at 1:41
• Perhaps my question 198323 could give you some ideas on how to deal with transformations. Oct 24 '20 at 1:41

You can transform a GraphicsComplex too. For example:

Manipulate[
cow /. {GraphicsComplex[vtx_, args___] :>
GeometricTransformation[GraphicsComplex[vtx, args],
Dynamic[EulerMatrix[{α, β, γ}]]]}, \
{{α, 0}, 0, 2 Pi, Pi/32}, {{β, 0}, 0, 2 Pi,
Pi/32}, {{γ, 0}, 0, 2 Pi, Pi/32},
Initialization :> {cow := ExampleData[{"Geometry3D", "Cow"}]},
ControlPlacement -> Top]


# Update: Extend Response to Comment

If you look at the InputForm of the example data, you can see the GraphicsComplex

Short[InputForm[ExampleData[{"Geometry3D", "Phobos"}]], 5]
(* \!$$TagBox[ PaneBox["\<\"Graphics3D[{EdgeForm[], \ GraphicsComplex[{{-1.3601044416427612, 9.545239448547363, \ 0.0012262604432180524}, {-1.2952135801315308, 9.546309471130371, \ 0.36269038915634155}, {-0.7759165167808533, 9.590052604675293, \ 0.5633725523948669}, <<9405>>, {5.872391700744629, \ 3.5175044536590576, 9.917975425720215}, {-11.840780258178711, \ 2.7396738529205322, -4.5116286277771}}, <<2>>]}, Boxed -> False]\"\>"], Short[#, 5]& ]$$ *)


You can see that the GraphicsComplex contains a list of vertices or points and geometric entities that refer to the vertices by index.

You can use Cases to extract the GraphicsComplex by itself.

First@Cases[ExampleData[{"Geometry3D", "Phobos"}], _GraphicsComplex,
Infinity]


The geometric transform operates on the vertices only. If you want to extract the vertices and the argument separately, you can use:

With[{gc =
First@Cases[
ExampleData[{"Geometry3D", "Phobos"}], _GraphicsComplex,
Infinity]},
gc /. {GraphicsComplex[vtx_, args___] :> {vtx, args}}]


Here is an example of how to rotate Phobos:

phobos = ExampleData[{"Geometry3D", "Phobos"}];
With[{shape = phobos, a = 0, b = 0, c = 0},
shape /. {GraphicsComplex[vtx_, args___] :>
GeometricTransformation[GraphicsComplex[vtx, args],
EulerMatrix[{a, b, c}]]}]
With[{shape = phobos, a = 10, b = 5, c = 6},
shape /. {GraphicsComplex[vtx_, args___] :>
GeometricTransformation[GraphicsComplex[vtx, args],
EulerMatrix[{a, b, c}]]}]


# Update: Space Shuttle Request for Alex

Manipulate[
spaceshuttle /. {GraphicsComplex[vtx_, args___] :>
GeometricTransformation[GraphicsComplex[vtx, args],
Dynamic[EulerMatrix[{α, β, γ}]]]}, \
{{α, 0}, 0, 2 Pi, Pi/32}, {{β, 0}, 0, 2 Pi,
Pi/32}, {{γ, 0}, 0, 2 Pi, Pi/32},
Initialization :> {spaceshuttle :=
ExampleData[{"Geometry3D", "SpaceShuttle"}]},
ControlPlacement -> Top]


• Good answer (+1). Could you replace image cow with "SpaceShuttle"? Oct 24 '20 at 10:54
• @Gluoncito I put an extended response in my answer. Oct 24 '20 at 16:40
• @AlexTrounev I added a Space Shuttle example. Oct 24 '20 at 16:49
• @Tim Laska, I deleted my earlier comment because I realized that GraphicsComplex was the "magic" word lacking when loading the 3D model. Your detailed response was very useful, thank you very much ! Oct 24 '20 at 16:55