Drawing a Rotated Rectangle

后端 未结 6 802
情歌与酒
情歌与酒 2020-12-06 17:43

I realize this might be more of a math problem.

To draw the lines for my rectangles I need to solve for their corners. I have a rectangle center at (x,y) With a def

6条回答
  •  北荒
    北荒 (楼主)
    2020-12-06 18:13

    One of the easiest ways to do this is to take the location of the point before rotation and then apply a coordinate transform. Since it's centred on (0,0), this is simply a case of using:

    x' = x cos(theta) - y sin(theta)

    y' = y cos(theta) + x sin(theta)

提交回复
热议问题