6
$\begingroup$

When I rotate objects they change size. Is there a way to fix it?

Below are 2 different attempts with the same result. I even tried to put transparent sphere around it, but the problem remained.

The examples below are for octahedron (the simplest example I could think of), but I'm looking for a method, that works for every 3D Graphics.

Also the image size should stay fixed because i will make mp4 out of images

Thanks in advance.

ATTEMPT 1

<< TetGenLink`
{coords, incidences} = TetGenConvexHull[{
    {1, 0, 0},
    {0, 1, 0},
    {0, 0, 1},
    -{1, 0, 0},
    -{0, 1, 0},
    -{0, 0, 1}
    }];

Manipulate[
 Show[
  Graphics3D[{
    EdgeForm[],
    FaceForm[Cyan],
    GraphicsComplex[coords, Polygon[incidences]]}],
  Background -> Black,
  Boxed -> False,
  ImageSize -> {1920, 1080},
  ViewPoint -> {1000000 Cos[t], 1000000 Sin[t], 1000000}
  ]
 , {t, 0, -2 \[Pi]}]

ATTEMPT 2

<< TetGenLink`

Manipulate[
 {coords, incidences} = TetGenConvexHull[{
    {Cos[t], Sin[t], 0},
    {Cos[t + \[Pi]/2], Sin[t + \[Pi]/2], 0},
    {0, 0, 1},
    -{Cos[t], Sin[t], 0},
    -{Cos[t + \[Pi]/2], Sin[t + \[Pi]/2], 0},
    -{0, 0, 1}
    }];
 Show[
  Graphics3D[{
    EdgeForm[],
    FaceForm[Cyan],
    GraphicsComplex[coords, Polygon[incidences]]}],
  Background -> Black,
  Boxed -> False,
  ImageSize -> {1920, 1080},
  ViewPoint -> {0, -1000000, 1000000}
  ]
 , {t, 0, 2 \[Pi]}]
$\endgroup$
0
4
$\begingroup$

Your problems with the object scale appearing to change as the object rotates is because of the default "Orthographic" projection. Use ViewProjection->"Perspective" instead, and reduce the view distance to make the object appear larger. The rest of this answer discusses the problems I experienced with "Orthographic" clipping/z-fighting at certain viewing angles with a very distant ViewPoint:


Any weird clipping effects that pop in and out as you rotate it are caused by z-fighting problems or the default orthographic far-plane being too shallow for your long viewing distance.

Manipulate[
 Show[Graphics3D[{EdgeForm[], FaceForm[Cyan], 
    GraphicsComplex[coords, Polygon[incidences]]}], 
  Background -> Black, Boxed -> False, ImageSize -> {300, 300}, 
  ViewPoint -> {1000000 Cos[t], 1000000 Sin[t], 1000000}], {t, 
  0, 2 \[Pi]}]

clipping problem

You can fix the clipping without changing the projection or viewpoint by using BSP trees instead of z-buffering:

Manipulate[Style[Show[
   Graphics3D[{EdgeForm[], FaceForm[Cyan], 
     GraphicsComplex[coords, Polygon[incidences]]}]
   , Background -> Black, Boxed -> False, ImageSize -> {300, 300}, 
   ViewPoint -> {1000000 Cos[t], 1000000 Sin[t], 1000000}],
  RenderingOptions -> {"3DRenderingMethod" -> "BSPTree"}], {t, 
  0, 2 \[Pi]}]
$\endgroup$
4
$\begingroup$

I think you can use the option SphericalRegion for this purpose:

Animate[
    Graphics3D[{Octahedron[{t,-Pi/2}]}, 
        Boxed->False,
        SphericalRegion->Sphere[{0,0,0},1]
    ],
    {t,0,2Pi}
]

enter image description here

$\endgroup$
2
$\begingroup$

ViewPoint is not able to guarantee the fixed size of a viewed object if not set fixed. If ViewPoint is changed, the position is closer or distant depending on the length of the vector entered in the option ViewPoint.

Look at this:

Manipulate[
 Style[Show[
   Graphics3D[{EdgeForm[], Cyan, 
     Line[{{0, 0, 0}, {3 Cos[t], 3 Sin[t], 3}}], Opacity[0.0], 
     Sphere[{0, 0, 0}, 3]}], Background -> White, Boxed -> False, 
   ImageSize -> {300, 300}, ViewPoint -> {3 Cos[t], 3 Sin[t], 3}], 
  RenderingOptions -> {"3DRenderingMethod" -> "BSPTree"}], {t, 
  0, -2 \[Pi]}]

enter image description here

So a proper solution is

Manipulate[
 Graphics3D[{EdgeForm[], FaceForm[Cyan], 
   GeometricTransformation[
    GraphicsComplex[coords, Polygon[incidences]], 
    RotationTransform[k Pi/8, {1, 0, 0}]], Opacity[0.0], 
   Sphere[{0, 0, 0}, 1.5]} , Background -> Black, Boxed -> False, 
  ImageSize -> {300, 300}], {k, -8, 8}, SaveDefinitions -> True]

anition of fixed box rotation

The strategy is (i) replace the active rotation by a passive one using RotationTransform. (ii) put a sphere in the Graphics3D to avoid the activation of the automatic adoption of the bounding box to be adopted to the view frustum in your active Notebook. The inserted Sphere around the graphics object keeps this automatism fixed as long as the sphere surrounds the graphics object complete. To get near the object in view fit the radius to the widest diameter of the graphics object.

$\endgroup$

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.