(*^ ::[ Information = "This is a Mathematica Notebook file. It contains ASCII text, and can be transferred by email, ftp, or other text-file transfer utility. It should be read or edited using a copy of Mathematica or MathReader. If you received this as email, use your mail application or copy/paste to save everything from the line containing (*^ down to the line containing ^*) into a plain text file. On some systems you may have to give the file a name ending with ".ma" to allow Mathematica to recognize it as a Notebook. The line below identifies what version of Mathematica created this file, but it can be opened using any other version as well."; FrontEndVersion = "Macintosh Mathematica Notebook Front End Version 2.2"; MacintoshStandardFontEncoding; fontset = title, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L2, e8, 20, "New York"; fontset = subtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L2, e6, 14, "New York"; fontset = subsubtitle, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeTitle, center, M7, bold, L2, e6, 12, "New York"; fontset = section, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, grayBox, M22, bold, L2, a20, 12, "New York"; fontset = subsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, blackBox, M19, bold, L2, a15, 12, "New York"; fontset = subsubsection, inactive, noPageBreakBelow, nohscroll, preserveAspect, groupLikeSection, whiteBox, M18, bold, L2, a12, 10, "New York"; fontset = text, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L2, 12, "New York"; fontset = smalltext, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L2, 10, "New York"; fontset = input, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeInput, M42, N23, bold, L2, 12, "Courier"; fontset = output, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L2, 12, "Courier"; fontset = message, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, R65535, L2, 12, "Courier"; fontset = print, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L2, 12, "Courier"; fontset = info, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeOutput, M42, N23, L2, 12, "Courier"; fontset = postscript, PostScript, formatAsPostScript, output, inactive, noPageBreakInGroup, nowordwrap, preserveAspect, groupLikeGraphics, M7, l34, w282, h287, L2, 12, "Courier"; fontset = name, inactive, nowordwrap, nohscroll, noKeepOnOnePage, preserveAspect, M7, italic, B65535, L2, 10, "Geneva"; fontset = header, inactive, noKeepOnOnePage, preserveAspect, M7, L2, 10, "Times"; fontset = leftheader, inactive, L2, 10, "Times"; fontset = footer, inactive, noKeepOnOnePage, preserveAspect, center, M7, L2, 12, "Times"; fontset = leftfooter, inactive, center, L2, 12, "Times"; fontset = help, inactive, nohscroll, noKeepOnOnePage, preserveAspect, M7, L2, 10, "Geneva"; fontset = clipboard, inactive, noKeepOnOnePage, preserveAspect, M7, L2, 12, "New York"; fontset = completions, inactive, nowordwrap, noKeepOnOnePage, preserveAspect, M7, L2, 12, "New York"; fontset = special1, inactive, nowordwrap, noKeepOnOnePage, preserveAspect, M7, L2, 12, "New York"; fontset = special2, inactive, nowordwrap, noKeepOnOnePage, preserveAspect, center, M7, L2, 12, "New York"; fontset = special3, inactive, nowordwrap, noKeepOnOnePage, preserveAspect, right, M7, L2, 12, "New York"; fontset = special4, inactive, nowordwrap, noKeepOnOnePage, preserveAspect, M7, L2, 12, "New York"; fontset = special5, inactive, nowordwrap, noKeepOnOnePage, preserveAspect, M7, L2, 12, "New York"; paletteColors = 256; useSolids; currentKernel; ] :[font = input; dontPreserveAspect; startGroup] (**Homogeneous Transformations in 2 and 3 dimensions under the pre-multiplication convention **) (* © Jacques J. Vidal, 1990 *) BeginPackage["HomogeneousTransformations`"] homogenize::usage = "homogenize[u] appends a unity element to a 2- or 3-list" dehomogenize::usage = "dehomogenize[u] divides every element of a list by the last element, then remove the last element (now equal to 1) from the list." (** Two dimensions **) rotationMatrix2D::usage = "rotationMatrix2D[theta] returns the matrix for rotation by an angle theta in two dimensions." rotationMatrix2D::usage = "rotationMatrix2D[theta,{cx,cz}] returns the matrix for rotation by an angle theta around a center point in two dimensions." scalingMatrix2D::usage = "scalingMatrix2D[{sx,sy}] returns the matrix for scaling around the origin in two dimensions, by sx in the x-direction and sy in the y-direction" translationMatrix2D::usage = "translationMatrix2D[{tx,ty}] returns the matrix for translating by tx and ty in two dimensions" (** Three dimensions **) xRotationMatrix3D::usage = "xRotationMatrix3D[phi] returns the matrix for rotation by the angle phi around the x-axis in three dimensions." yRotationMatrix3D::usage = "yRotationMatrix3D[psi] returns the matrix for rotation by the angle psi around the y-axis in three dimensions." zRotationMatrix3D::usage = "zRotationMatrix3D[theta] returns the matrix for rotation by the angle theta around the z-axis in three dimensions." rotationMatrix3D::usage = "rotationMatrix3D[phi,psi,theta] returns the matrix for rotation by the specified Euler angles in three dimensions." rotationMatrix3D::usage = "rotationMatrix3D[phi,psi,theta,{cx,cy,cz}] returns the matrix for rotation by the specified Euler angles around a center point {cx,cy,cz} in three dimensions.(to be implemented)" scalingMatrix3D::usage = "scalingMatrix3D[{sx,sy,sz}] returns the matrix for scaling around the origin in three dimensions, by sx in the x-directiion,sy in the y-direction, and sz in the z-direction" translationMatrix3D::usage = "translationMatrix3D[{tx,ty,tz}] returns the matrix for translating by tx, ty and tz in three dimensions" (******************************************************) Begin["`private`"] homogenize[vec:{_,_}]:=Append[vec,1] deHomogenize[vec:{_,_,_}]:=Drop[vec/(Last[vec]),-1] homogenize[vec:{_,_,_}]:=Append[vec,1] deHomogenize[vec:{_,_,_,_}]:=Drop[vec/(Last[vec]),-1] normalize[vec:_List]:= vec/Sqrt[Apply[Plus,vec^2]] rotationMatrix2D[theta_] := Transpose[ {{Cos[theta], Sin[theta], 0}, {-Sin[theta], Cos[theta], 0}, {0,0,1}}] rotationMatrix2D[theta_,{cx_,cy_}] := Transpose[ {{Cos[theta], Sin[theta], 0}, {-Sin[theta], Cos[theta], 0}, {(1-Cos[theta])cx +(Sin[theta])cy, (1-Cos[theta])cy -(Sin[theta])cx,1}}] scalingMatrix2D[{sx_,sy_}] := Transpose[ { {sx,0,0},{0,sy,0},{0,0,1} }] scalingMatrix2D[{sx_,sy_},{cx_,cz_}] := Transpose[ { {sx,0,0},{0,sy,0},{(1-sx)cx, (1-sy)cy, 1} }] translationMatrix2D[{tx_,ty_}] := Transpose[ { {1,0,0},{0,1,0},{tx,ty,1} }] xRotationMatrix3D[phi_] := Transpose[ { {1, 0, 0, 0}, {0, Cos[phi], Sin[phi],0}, {0,-Sin[phi], Cos[phi],0}, {0, 0, 0, 1} }] yRotationMatrix3D[psi_] := Transpose[ { {Cos[psi], 0, -Sin[psi], 0}, {0, 1, 0, 0}, {Sin[psi], 0, Cos[psi], 0}, {0, 0, 0, 1} }] zRotationMatrix3D[theta_]:= Transpose[{ {Cos[theta], Sin[theta], 0,0}, {-Sin[theta], Cos[theta], 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 1} }] rotationMatrix3D[{phi_,theta_,psi_}] := Transpose[ { { Cos[psi] Cos[phi] - Cos[theta] Sin[phi] Sin[psi], Cos[psi] Sin[phi] + Cos[theta] Cos[phi] Sin[psi], Sin[psi] Sin[theta],0 } , { -Sin[psi] Cos[phi] - Cos[theta] Sin[phi] Cos[psi], -Sin[psi] Sin[phi] + Cos[theta] Cos[phi] Cos[psi], Cos[psi] Sin[theta],0 } , { Sin[theta] Sin[phi], -Sin[theta] Cos[phi], Cos[theta],0 },{0,0,0,1} }] (*rotationMatrix3D[{theta_, phi_, psi_}, {cx_,cy_,cz_}] =.*) scalingMatrix3D[{sx_,sy_,sz_}] := Transpose[ { {sx,0,0,0},{0,sy,0,0},{0,0,sz,0},{0,0,0,1} }] scalingMatrix3D[{sx_,sy_,sz_},{cx_,cy_,cz}] := Transpose[ { {sx,0,0,0},{0,sy,0,0},{0,0,sz,0}, {(1-sx)cx, (1-sy)cy,(1-sz)cz, 1} }] translationMatrix3D[{tx_,ty_,tz_}] := Transpose[ { {1,0,0,0},{0,1,0,0},{0,0,1,0},{tx,ty,tz,1} }] End[] EndPackage[ ] Null; :[font = output; output; inactive; preserveAspect] "HomogeneousTransformations`" ;[o] HomogeneousTransformations` :[font = output; output; inactive; preserveAspect] "homogenize[u] appends a unity element to a 2- or 3-list" ;[o] homogenize[u] appends a unity element to a 2- or 3-list :[font = output; output; inactive; preserveAspect] "dehomogenize[u] divides every element of a list by the last\ element, then remove the last element (now equal to 1) from the\ list." ;[o] dehomogenize[u] divides every element of a list by the last\ element, then remove the last element (now equal to 1) from the\ list. :[font = output; output; inactive; preserveAspect] "rotationMatrix2D[theta] returns the matrix for rotation by an\ angle theta in two dimensions." ;[o] rotationMatrix2D[theta] returns the matrix for rotation by an\ angle theta in two dimensions. :[font = output; output; inactive; preserveAspect] "rotationMatrix2D[theta,{cx,cz}] returns the matrix for rotation\ by an angle theta around a center point in two dimensions." ;[o] rotationMatrix2D[theta,{cx,cz}] returns the matrix for rotation by\ an angle theta around a center point in two dimensions. :[font = output; output; inactive; preserveAspect] "scalingMatrix2D[{sx,sy}] returns the matrix for scaling around\ the origin in two dimensions, by sx in the x-direction and sy in\ the y-direction" ;[o] scalingMatrix2D[{sx,sy}] returns the matrix for scaling around the\ origin in two dimensions, by sx in the x-direction and sy in the\ y-direction :[font = output; output; inactive; preserveAspect] "translationMatrix2D[{tx,ty}] returns the matrix for translating\ by tx and ty in two dimensions" ;[o] translationMatrix2D[{tx,ty}] returns the matrix for translating by\ tx and ty in two dimensions :[font = output; output; inactive; preserveAspect] "xRotationMatrix3D[phi] returns the matrix for rotation by\ the angle phi around the x-axis in three dimensions." ;[o] xRotationMatrix3D[phi] returns the matrix for rotation by\ the angle phi around the x-axis in three dimensions. :[font = output; output; inactive; preserveAspect] "yRotationMatrix3D[psi] returns the matrix for rotation by\ the angle psi around the y-axis in three dimensions." ;[o] yRotationMatrix3D[psi] returns the matrix for rotation by\ the angle psi around the y-axis in three dimensions. :[font = output; output; inactive; preserveAspect] "zRotationMatrix3D[theta] returns the matrix for rotation\ by the angle theta around the z-axis in three\ dimensions." ;[o] zRotationMatrix3D[theta] returns the matrix for rotation\ by the angle theta around the z-axis in three dimensions. :[font = output; output; inactive; preserveAspect] "rotationMatrix3D[phi,psi,theta] returns the matrix for\ rotation by the specified Euler angles in three\ dimensions." ;[o] rotationMatrix3D[phi,psi,theta] returns the matrix for\ rotation by the specified Euler angles in three\ dimensions. :[font = output; output; inactive; preserveAspect] "rotationMatrix3D[phi,psi,theta,{cx,cy,cz}] returns the\ matrix for rotation by the specified Euler angles\ around a center point {cx,cy,cz} in three dimensions.(to\ be implemented)" ;[o] rotationMatrix3D[phi,psi,theta,{cx,cy,cz}] returns the\ matrix for rotation by the specified Euler angles\ around a center point {cx,cy,cz} in three dimensions.(to\ be implemented) :[font = output; output; inactive; preserveAspect] "scalingMatrix3D[{sx,sy,sz}] returns the matrix for scaling\ around the origin in three dimensions, by sx in the\ x-directiion,sy in the y-direction, and sz in the z-direction" ;[o] scalingMatrix3D[{sx,sy,sz}] returns the matrix for scaling around\ the origin in three dimensions, by sx in the x-directiion,sy in\ the y-direction, and sz in the z-direction :[font = output; output; inactive; preserveAspect] "translationMatrix3D[{tx,ty,tz}] returns the matrix for\ translating by tx, ty and tz in three dimensions" ;[o] translationMatrix3D[{tx,ty,tz}] returns the matrix for translating\ by tx, ty and tz in three dimensions :[font = output; output; inactive; preserveAspect] "HomogeneousTransformations`private`" ;[o] HomogeneousTransformations`private` :[font = output; output; inactive; preserveAspect; endGroup] "HomogeneousTransformations`private`" ;[o] HomogeneousTransformations`private` ^*)