0
$\begingroup$

Using the example code from the cuboid:

Graphics3D[{Opacity[0.3], EdgeForm[],Table[{ColorData["Rainbow"][Rescale[c, {0, 2 Pi}]],GeometricTransformation[Cuboid[],RotationTransform[c, {-1, 2, -3},{1.5, 0, 0}]]}, {c, 0, 2 Pi, 2 Pi/12}]}]

I'm trying to manipulate it so it shows one image after the other. I changed it in this way:

Manipulate[Graphics3D[{Opacity[0.3],EdgeForm[], {ColorData["Rainbow"][Rescale[a, {0, 2 Pi}]],GeometricTransformation[Cuboid[],RotationTransform[a, {-1, 2, -3}, {1.5, 0, 0}]]}}], {a, 0, 2 Pi}]

But that doesn't keep the same scale, I wanted to show one cube at a time but in the way displayed in the first code.

$\endgroup$
2
$\begingroup$

Here's a simple trick that does what you want. We can include a transparent sphere in our scene that is large enough that MMA does not zoom in on each successive the cuboid. We can do that by adding Opacity[0],Sphere[center,radius] to our list of graphics directives, but what center and what radius should we use?

A check of the documentation for RotationTransformation shows that the rotation is about an axis through the anchor point {1.5,0,0}, so we can use that as our center. How big should the sphere be? Maybe a 1.5 radius, maybe a little bigger. We don't want to make it too big.

A little experimentation gives the following code with a radius of 2, which seems to work well.

Manipulate[Graphics3D[{
   Opacity[0.03], Sphere[{1.5, 0, 0}, 2],
   Opacity[0.3], EdgeForm[], {
    ColorData["Rainbow"][Rescale[a, {0, 2 Pi}]],
    GeometricTransformation[Cuboid[],
     RotationTransform[a, {-1, 2, -3}, {1.5, 0, 0}]]
    }}],
 {a, 0, 2 Pi}]

Your Manipulate works pretty good. In the above, the sphere shows faintly, just so we can see it. Change its opacity to zero for complete transparency.

$\endgroup$
  • $\begingroup$ What a simple solution! Worked perfectly, thank you! $\endgroup$ – Joseph Dec 6 '16 at 22:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.