Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.3K Views
|
3 Replies
|
1 Total Like
View groups...
Share
Share this post:

Rotating square's points

Posted 3 years ago

Hi, I'm trying to make a function to rate a square within a square, thus the second square will form a diamond.

I'm pretty new, so I think NestList is the way to go, however, I'm not sure how to rotate the coordinates of my polygon.

squarePts =  {{0, 0}, {1, 0}, {1, 1}, {0, 1}};

f7 = NestList[# ?? &, squarePts , 1]

I tried to get the middle points of each side and then rotate by 45 degree, but after the second square the thing become messy.

Thank you

POSTED BY: Isaac Keith
3 Replies
Posted 3 years ago

Crossposted here.

POSTED BY: Updating Name
Posted 3 years ago

For a more general solution, you might want to apply the transformation functions ScalingTransform and RotationTransform:

SquareTunnel[angle_, count_] :=
 With[
  {vertices0 = {{1, 1}, {-1, 1}, {-1, -1}, {1, -1}}},
  With[
   {center = Mean[vertices0], scale = (1/(Cos[angle] + Sin[angle]))},
   NestList[
    ScalingTransform[{scale, scale}]@*RotationTransform[angle, center], 
    vertices0, 
    count]]];

Graphics[{FaceForm[None], EdgeForm[Black], Polygon[SquareTunnel[Pi/8, 4]]}]

enter image description here

POSTED BY: Eric Rimbey
Posted 3 years ago
POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard