MathGroup Archive 2009

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

Search the Archive

Re: Rotating a list of 3D point coordinates in one shot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg100023] Re: Rotating a list of 3D point coordinates in one shot
  • From: "Marc B. Reynolds" <marc.reynolds at orange.fr>
  • Date: Fri, 22 May 2009 01:43:11 -0400 (EDT)

Something like this should be reasonable: create a 3x3 matrix once and apply (note verify the matrix, I only quickly spot checked it.)

rotate3D[p_, t_, {ax_, ay_, az_}] := Module[
  {s,w,x,y,z,m},

  s = Sin[t * .5]; (* evaluate terms *)
  w = Cos[t * .5];
  x = st ax;
  y = st ay;
  z = st az;
  m = {{1-2(y y + z z),   2(x y - w z),   2(w y + x z)},
       {  2(w z + x y), 1-2(x x + z z),   2(y z - w x)},
       {  2(x z - w y),   2(w x + y z), 1-2(x x + y y)}};
    
  If[MatrixQ[p], Map[Chop[Dot[m, #]] &, p], Chop[m.p]]
]


  • Prev by Date: Re: Integrate Bug
  • Next by Date: NIntegrate & Integrate
  • Previous by thread: Rotating a list of 3D point coordinates in one shot
  • Next by thread: Re: Rotating a list of 3D point coordinates in one shot