MathGroup Archive 2008

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

Search the Archive

Re: Rotation about 3 principal axes

  • To: mathgroup at smc.vnet.net
  • Subject: [mg94214] Re: Rotation about 3 principal axes
  • From: robert prince-wright <robertprincewright at yahoo.com>
  • Date: Mon, 8 Dec 2008 06:21:16 -0500 (EST)
  • References: <ghavrq$obo$1@smc.vnet.net> <6feacc87-4835-41c1-9302-fefaa0284d2f@x14g2000yqk.googlegroups.com>

thanks Maxim, 

nesting the Manipulators in this way is a pretty neat demonstration of how deep the Mathematica implementation of Manipulate goes!  In truth, it occurred to me that I was not solving my problem in the correct way. I've therefore switched to an Euler Z-Y-Z rotation sequence which allows a full range of manipulation - albeit at the expense of being less easy to comprehend. 

Robert 




________________________________
From: "m.r at inbox.ru" <m.r at inbox.ru>
To: robert prince-wright <robertprincewright at yahoo.com>
Sent: Sunday, December 7, 2008 2:56:57 AM
Subject: [mg94214] Re: Rotation about 3 principal axes



robert prince-wright wrote:
> Can someone help me change the code below.
>
> The  manipulate is meant to represent the effect of rotating a local coordinate set about angles 'ax', 'ay', 'az', these angles should be rotations about the global coordinates. If you use the sliders independently (i.e. with the other two angles set to zero) then it behaves as expected. However, if you change angle 'ay' to 90 (blue line downwards) and then slide 'ax' then the local coordinates rotate about the global z and not the desired global x. Somehow it is not using the rotation vectors inside the RotationTransform[ ]. I have tried various combinations including the use of Rotate[g,w,p], but the same think keeps happening.
>
>
>
> Manipulate[
>  LCposition = N[{0, 0, 0}];
>  xLocal := Line[{LCposition, LCposition + {1 , 0., 0.}}];
>  yLocal := Line[{LCposition, LCposition + {0., 1 , 0.}}];
>  zLocal := Line[{LCposition, LCposition + {0., 0., 1 }}];
>  lc = {Thick, Blue, xLocal, Green, yLocal, Red, zLocal};
>
>  Rx := RotationTransform[ ax Degree, {1, 0, 0}, {0, 0, 0}];
>  Ry := RotationTransform[ ay Degree, {0, 1, 0}, {0, 0, 0}];
>  Rz := RotationTransform[ az Degree, {0, 0, 1}, {0, 0, 0}];
>
>  gx := GeometricTransformation[lc, Rx];
>  gy := GeometricTransformation[gx, Ry];
>  gz := GeometricTransformation[gy, Rz];
>
>  Graphics3D[gz, PlotRange -> {{-3, 3}, {-3, 3}, {-3, 3}}],
>  {{ax, 0}, -360, 360, 1, Appearance -> "Labeled"},
>  {{ay, 0}, -360, 360, 1, Appearance -> "Labeled"},
>  {{az, 0}, -360, 360, 1, Appearance -> "Labeled"}
> ]

Hi Robert,

if you want the x slider to always rotate the scene about the fixed x
axis and so on, you shouldn't expect that moving all the sliders to
the zero position will get the original scene back, e.g., consider

RotationMatrix[-Pi/2, {0, 1, 0}].RotationMatrix[-Pi/2, {1, 0, 0}].
RotationMatrix[Pi/2, {0, 1, 0}].RotationMatrix[Pi/2, {1, 0, 0}]

Here's some code that I believe does what you want:

p = {0, 0, 0};
scene = {Thick,
   {Blue, Line[{p, p + {1, 0, 0}}]},
   {Green, Line[{p, p + {0, 1, 0}}]},
   {Red, Line[{p, p + {0, 0, 1}}]}};
m = IdentityMatrix[3];
Manipulate[
Graphics3D[Dynamic@ GeometricTransformation[scene, m], PlotRange ->
3],
{{ax, 0}, -360, 360, 1, Manipulator[
    Dynamic[ax, (m = RotationMatrix[1. Degree (# - ax), {1, 0, 0}].m;
ax = #)&], #2]&},
{{ay, 0}, -360, 360, 1, Manipulator[
    Dynamic[ay, (m = RotationMatrix[1. Degree (# - ay), {0, 1, 0}].m;
ay = #)&], #2]&},
{{az, 0}, -360, 360, 1, Manipulator[
    Dynamic[az, (m = RotationMatrix[1. Degree (# - az), {0, 0, 1}].m;
az = #)&], #2]&}]

Best regards,
Maxim Rytin


  • Prev by Date: Re: Clever Tricky Solutions
  • Next by Date: Re: Parallel computing and JLink
  • Previous by thread: Re: Rotation about 3 principal axes
  • Next by thread: Grid[] problems with SpanFrom...