Group Abstract Group Abstract

Message Boards Message Boards

0
|
9.3K Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

How do I create a function to rotate a rectangle about its origin?

Posted 10 years ago
Attachments:
POSTED BY: Varun Kulkarni
5 Replies
POSTED BY: Gianluca Gorni
Posted 10 years ago

I wanted to try and use a 2x2 rotation matrix for the same. Define a 2x2 rotation matrix and then use this defined function inside Animate to rotate the Rectangle

Is there any way to do that?

POSTED BY: Varun Kulkarni
Posted 10 years ago

Is there any way that i can rotate this rectangle without using Geometric Transformation?

Say, multiply every end coordinate of the rectangle with the function defined for the rotation matrix?

Multiply every end coordinate with rot [a] where rot[a] := {{Cos[a], -Sin[a]}, {Sin[a], Cos[a]}}; ?

POSTED BY: Varun Kulkarni

It can be shortened to an almost one-liner:

Animate[Graphics[Rotate[Rectangle[{-2.5, -0.5}, {2.5, 0.5}], a], 
  Axes -> True, PlotRange -> 10], {a, 0, 2 \[Pi]}]
POSTED BY: Gianluca Gorni

may be

ClearAll[rot,a]
rot[a_] := {{Cos[a], -Sin[a]}, {Sin[a], Cos[a]}};
R0 = Rectangle[{-2.5, -0.5}, {2.5, 0.5}];
Animate[Graphics[GeometricTransformation[R0, rot[a]], Axes -> True, 
  PlotRange -> {{-10, 10}, {-10, 10}}], {a, 0, 2 \[Pi]}]
POSTED BY: Nasser M. Abbasi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard