Message Boards Message Boards

0
|
1980 Views
|
1 Reply
|
1 Total Likes
View groups...
Share
Share this post:

ViewPoint in Scaled Cylindrical Coordinate

Recently I had the chance to look at Viewpoint in Graphics3D more closely. Instead of Cartesian coordinates X, Y, Z , it seems more natural for a photographer to use the cylindrical coordinate system of radius, angle and height. Below is the geometry for Cylindrical Coordinate r=2, theta= 45 Degree, z = 1 1/2:

p = {2 Cos[45 Degree], 2 Sin[45 Degree], 1 + 1/2};
Graphics3D[ {
  Opacity[.05], Green, Cuboid[{-2, -2, -2}, {2, 2, 2}],
  (*object*)
  Opacity[1], Yellow, 
  PolyhedronData["Dodecahedron", "GraphicsComplex"],
  Opacity[.15], Blue, Cuboid[{-1, -1, -1}, {1, 1, 1}],
  (*cylinder*)
  Opacity[.35], Green, EdgeForm[{Thick, Black}], 
  Cylinder[{{0, 0, -2}, {0, 0, 2}}, 2], Opacity[0], White, 
  Cylinder[{{0, 0, -2}, {0, 0, 0}}, 2],
  (*ViewPoint*)
  Opacity[1], Black, Arrow[{p, {0, 0, 0}}],
  (*Guides0: Plane, Points,Arrow,Circle*)
  Opacity[.90], Gray, Polygon[{{0, 0, 0}, {p[[1]], p[[2]], 0}, p}], 
  Polygon[{{2, 2, 0}, {2, -2, 0}, {-2, -2, 0}, {-2, 2, 0}}],
  Opacity[.0], White, EdgeForm[{Thick, Red}], 
  Cylinder[{{0, 0, p[[3]] - .01}, {0, 0, p[[3]]}}, 2],
  Opacity[1], Red, PointSize[Large], Point[p], 
  Point[{p[[1]], p[[2]], 0}],
  Inset[Style[
    "ViewPoint-> Cylindrical Coordinate r=2,\[Theta] = 45°,z=1 1/2", 
    12], p + {0, 0, .1}], Inset["{2,2,2}", {2, 2, 2}], 
  Inset["{-2,-2,-2}", {-2, -2, -2}]}, ImageSize -> 1080*4/8, 
 Boxed -> False]

Geometry for using scaled cylindrical coordinates for Viewpoint in Graphics3D

The conversion is fairly straight forward with r and z both limited to -2 and 2 and angle 0 to 2Pi.

ViewPoint->{ r Cos[theta], r Sin[theta], z}

To fix the view in an lazy susan rotation animation to eliminate view resizing, ViewAngle can be added:

pt[\[Theta]_] := {2 Cos[\[Theta]], 2 Sin[\[Theta]], 2}
Manipulate[Graphics3D[ {
   Opacity[.05], Green, Cuboid[{-2, -2, -2}, {2, 2, 2}],
   (*object*)
   Opacity[1], Yellow, 
   PolyhedronData["Dodecahedron", "GraphicsComplex"],
   Opacity[.15], Blue, Cuboid[{-1, -1, -1}, {1, 1, 1}],
   (*cylinder*)
   Opacity[.35], Green, EdgeForm[{Thick, Black}], 
   Cylinder[{{0, 0, -2}, {0, 0, 2}}, 2], Opacity[0], White, 
   Cylinder[{{0, 0, -2}, {0, 0, 0}}, 2]
   (*ViewPoint*),
   Opacity[1], Black, Arrow[{p, {0, 0, 0}}],
   (*Guides0: Plane, Points,Arrow,Circle*)
   Opacity[.90], Gray, Polygon[{{0, 0, 0}, {p[[1]], p[[2]], 0}, p}], 
   Polygon[{{2, 2, 0}, {2, -2, 0}, {-2, -2, 0}, {-2, 2, 0}}],
   Opacity[.0], White, EdgeForm[{Thick, Red}], 
   Cylinder[{{0, 0, p[[3]] - .01}, {0, 0, p[[3]]}}, 2],
   Opacity[1], Red, PointSize[Large], Point[p], 
   Point[{p[[1]], p[[2]], 0}],
   Inset[
    Style["ViewPoint-> Cylindrical Coordinate r=2,\[Theta] = 45°,z=1 \
1/2", 12], p + {0, 0, .1}], Inset["{2,2,2}", {2, 2, 2}], 
   Inset["{-2,-2,-2}", {-2, -2, -2}]}, ImageSize -> 1080*4/8, 
  Boxed -> False, ViewAngle -> 35 Degree, ViewPoint -> pt[t]], {t, 0, 
  2 Pi, .005}]
POSTED BY: Jack I Houng

gif animation of lazy susan rotation view with viewangle set to 35 Degree

animation of lazy susan rotation view with viewangle set to 35 Degree

POSTED BY: Jack I Houng
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract