MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Rotation of 3D objects

  • To: mathgroup at smc.vnet.net
  • Subject: [mg86283] Re: Rotation of 3D objects
  • From: "David Park" <djmpark at comcast.net>
  • Date: Fri, 7 Mar 2008 02:31:28 -0500 (EST)
  • References: <fqo8u2$t2s$1@smc.vnet.net>

Here is some code for those who have the Presentations package.

For reflection in a mirror:

Needs["Presentations`Master`"]

Module[
 {(* object to reflect *)
  gr = ParametricDraw3D[{t, u + t, u t/5}, {t, 0, 2}, {u, -1, 1},
    Mesh -> 5,
    BoundaryStyle -> Black],
  (* Mirror location and normal *)
  p = {1, 1, 2},
  normal = {0, 0, 1},
  vector1, vector2},
 {vector1, vector2} = NullSpace[{normal}];
 Draw3DItems[
  {(* Original object *)
   {Opacity[.7, HTML[DarkSeaGreen]], gr},
   (* Reflected object *)
   {Opacity[.7, HTML[DodgerBlue]], gr} //
    ReflectionTransformOp[normal, p],
   (* Draw the mirror *)
   {Opacity[0.3, HTML[SkyBlue]],
    ParametricDraw3D[
     p + s vector1 + t vector2, {s, -3, 3}, {t, -3, 3},
     Mesh -> None]}},
  NeutralLighting[0, 0.6, .1],
  NiceRotation,
  ViewPoint -> {2, -2.4, .6},
  Boxed -> False,
  ImageSize -> 300]
 ]

Multiple copies of rotation about an axis:

Module[
 {(* object to reflect *)
  gr = ParametricDraw3D[{t, u + t, u t/5}, {t, 0, 2}, {u, -1, 1},
    Mesh -> 5,
    BoundaryStyle -> Black],
  (* axis, location and number of copies *)
  axis = {1, 1, 0},
  axislocation = {-1.5, -1.5, 2},
  ncopies = 4,
  rotationangle},
 rotationangle = 2 \[Pi]/ncopies;
 Draw3DItems[
  {(* Rotations *)
   {Opacity[.7, HTML[DarkSeaGreen]],
    Table[gr //
      RotationTransformOp[n rotationangle, axis, axislocation], {n, 0,
       ncopies - 1}]},
   (* Draw the axis *)
   Red, Arrow3D[axislocation, axislocation + 5 axis, {.10}]},
  NeutralLighting[0, 0.6, .1],
  NiceRotation,
  ViewPoint -> {-1, -2.4, .6},
  Boxed -> False,
  ImageSize -> 300]
 ]

A Manipulate statement allowing the rotation about an axis by an adjustable 
angle theta.

Manipulate[
 Module[
  {(* object to reflect *)
   gr = ParametricDraw3D[{t, u + t, u t/5}, {t, 0, 2}, {u, -1, 1},
     Mesh -> 5,
     BoundaryStyle -> Black],
   (* axis direction and location *)
   axis = {1, 1, 0},
   axislocation = {-1.5, -1.5, 2}},
  Draw3DItems[
   {(* Original object *)
    {Opacity[.7, HTML[DarkSeaGreen]], gr},
    (* Rotated object *)
    {Opacity[.7, HTML[DodgerBlue]],
     gr // RotationTransformOp[\[Theta], axis, axislocation]},
    (* Draw the axis *)
    Red, Arrow3D[axislocation, axislocation + 5 axis, {.10}]},
   NeutralLighting[0, 0.6, .1],
   NiceRotation,
   PlotRange -> {{-1, 4}, {-1, 4}, {-1, 5}},
   ViewPoint -> {-1, -2.4, .6},
   Boxed -> False,
   ImageSize -> 300]
  ],
 Style["Rotation about axis by angle \[Theta]", 16],
 {\[Theta], 0, 2 \[Pi], Appearance -> "Labeled"}]


-- 
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/


"Narasimham" <mathma18 at hotmail.com> wrote in message 
news:fqo8u2$t2s$1 at smc.vnet.net...
> By what command is it possible to create (without writing a code
> separately ):
>
> 1) Reflections of 3D objects about a plane?
>
> 2) Multiple copies equally spaced  by rotation around an axis through
> two given points?
>
> E.g.,
> surf = ParametricPlot3D[{ t,u+t, u*t/5}, {t,0,2},{u,-1,1}];
> Rotate[surf,Axis->{ {-1,-1,-1},{1,1,1}} , Copies-> 4 ] ;     and,
>
> 3) A single rotation of given object through a given angle on an axis
> through two defined points?
>
> Thanks in advance
>
> Narasimham
> 



  • Prev by Date: Re: Writing a HoldAll function that evaluates its arguments
  • Next by Date: Re: Troubling Bug involving RandomReal, NestList, and Table
  • Previous by thread: Re: Rotation of 3D objects
  • Next by thread: Re: Rotation of 3D objects