Re: Rotating Figures

• To: mathgroup at smc.vnet.net
• Subject: [mg15260] Re: Rotating Figures
• From: Karen Abbott <kabbott at cowan.edu.au>
• Date: Wed, 30 Dec 1998 01:50:23 -0500
• Organization: International English Centre
• References: <764t0p\$bj2@smc.vnet.net>
• Sender: owner-wri-mathgroup at wolfram.com

```Wilson Figueroa wrote:

> Does anyone know how an entire figure can be passed to Mathematica and
> have that figure rotated by either a 2D or 3D transformation?
>
> For example, I could have a rotation matrix of:
>
> rot[{x_,y_}]:= {{a,b},{c,d}}.{x,y}
>
> This would take every point in the figure, apply the transformation, and
> them replot the figure.
>
> I would like to be able to do this with 2D and 3D figures or data ... as
> the case may be.

I think that the appended Notebook will do what you want.

Cheers,
Paul

Notebook[{

Cell[CellGroupData[{
Cell["Affine Transformations", "Subsection",
Evaluatable->False,
AspectRatioFixed->True],

Cell[TextData[{
"See ",
StyleBox["Mathematica Graphics: Techniques & Applications",
FontSlant->"Italic"],
" by Tom Wickam-Jones and The ",
StyleBox["Mathematica",
FontSlant->"Italic"],
" Journal 4(3):38-39."
}], "Text",
Evaluatable->False,
AspectRatioFixed->True],

Cell[TextData[{
"An arbitrary affine transformation (that is, a composition of
translation, \
rotation, and scaling) of a vector ",
Cell[BoxData[
\(TraditionalForm\`{x, y}\)]],
" in the plane can be be written in matrix notation as ",
Cell[BoxData[
\(TraditionalForm\`m . {x, y}\  + \ c\)]],
", where ",
Cell[BoxData[
\(TraditionalForm\`m\)]],
" is a ",
Cell[BoxData[
\(TraditionalForm\`2\[Times]2\)]],
" matrix (generating rotation and scaling) and ",
Cell[BoxData[
\(TraditionalForm\`c\)]],
" is a constant (translation) vector." }], "Text",
CellTags->{"affine transformation", "translation", "rotation",
"scaling"}],

Cell["\<\
Here is a simple procedure that applies affine transformations to \
two-dimensional graphics:\
\>", "Text",
CellTags->"applying affine transformation to graphics"],

Cell[BoxData[
\(Affine[plot_Graphics, m_?MatrixQ, c_?VectorQ] :=
Show[plot /. {x_?NumberQ, y_?NumberQ} \[Rule] m . {x, y} + c]\)],
"Input",
AspectRatioFixed->True],

Cell["Commencing with a basic plot:", "Text"],

Cell[BoxData[
\(\(SinPlot = Plot[Sin[x], {x, 0, 6\ \[Pi]}]; \)\)], "Input",
AspectRatioFixed->True],

Cell[TextData[{
"one can rotate it about the ",
Cell[BoxData[
\(TraditionalForm\`z\)]],
"-axis by 90 degrees and then mirror it in the ",
Cell[BoxData[
\(TraditionalForm\`y\)]],
"-axis:"
}], "Text"],

Cell[BoxData[
\(\(Affine[SinPlot, {{0, 1}, {1, 0}}, {0, 0}]; \)\)], "Input",
AspectRatioFixed->True],

Cell["\<\
or display a more complicated combination of rotation, scaling, and \
translation:\
\>", "Text"],

Cell[BoxData[
\(\(Affine[SinPlot, {{1, 0}, {1, 3}}, {\(-1\), \(-2\)}]; \)\)],
"Input",
AspectRatioFixed->True]
}, Open  ]]
}
]

```

• Prev by Date: PrimeQ[Floor[Pi*10^i]]
• Next by Date: Consultant Wanted
• Previous by thread: Re: Rotating Figures
• Next by thread: Matrix Problem