1
$\begingroup$

Can I use Mathematica to create visualized rotation of a shape? Specifically, I'm trying to draw a rectangle $R$ with vertices where $r>0$ and $\theta\in(0,\pi/4$):

$$ \\ R= \begin{pmatrix} re^{i\theta} \\ -re^{-i\theta} \\ -re^{i\theta} \\ re^{-i\theta} \end{pmatrix}$$

Then rotating it by $2\theta$ to create a 2nd rectangle $R'$ where:

$$R'= e^{i2\theta}*R = e^{i2\theta}\begin{pmatrix} re^{i\theta} \\ -re^{-i\theta} \\ -re^{i\theta} \\ re^{-i\theta} \end{pmatrix} = \begin{pmatrix} re^{i3\theta} \\ -re^{i\theta} \\ -re^{i3\theta} \\ re^{i\theta} \end{pmatrix}$$

Ideally the final graphic would start with $R$, then show a "shadow" of $R$ rotating to the position of $R'$. At the end, the graphic would show both $R$ and $R'$.

$\endgroup$
  • $\begingroup$ First you can use Graphics to draw your shapes parametrically and then use Animate or Manipulate to animate them. $\endgroup$ – L.Yu May 23 at 22:38
2
$\begingroup$

RotationTransform

RotationTransform[θ, p] gives a 2D rotation about the 2D point p.

Rotating the rectangle around a selected corner with trailing effects:

Manipulate[Graphics[{{EdgeForm[{Thick, Black}], FaceForm[], Rectangle[]}, 
   Table[GeometricTransformation[{EdgeForm[Opacity[.5 k/(t + 1/100), Gray]], 
     Opacity[.5 k/(t + 1/100)], Red, Rectangle[]}, RotationTransform[k, pt]], 
    {k, 0, t - 2 Pi/36, 2 Pi/36}], 
   GeometricTransformation[{EdgeForm[{Thick, Gray}], Opacity[.7], Red,
      Rectangle[]}, RotationTransform[t, pt]], 
   AbsolutePointSize[5], Green, Point[pt]}, PlotRange -> {{-2, 3}, {-2, 3}}], 
 {{pt, {1, 1}}, {{0, 0}, {0, 1}, {1, 0}, {1, 1}, {1/2, 1/2}}, SetterBar},
 {{t, 0}, 0, 2 Pi, Animator, AnimationRunning -> False},  FrameMargins -> 0]

enter image description here

Change the first control to {{pt, {1, 1}}, Locator} to rotate around an arbitrary point:

enter image description here

You can use arbitrary shape instead of Rectangle. For example, with

text = First[First[ImportString[ExportString[
      Style["A", Italic, FontSize -> 24, FontFamily -> "LucidaHandwriting"], 
   "PDF"], "PDF", "TextMode" -> "Outlines"]]];

replace Rectangle[] with text and use to PlotRange -> {{-32, 48}, {-32, 48}} to get

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.