Find corners of a rotated rectangle given its center point and rotation

后端 未结 3 1331
误落风尘
误落风尘 2021-01-15 08:12

Can someone give me an algorithm that finds the position of all four corners of a rectangle if I know its center point(in global coordinate space), width and height, and its

3条回答
  •  执念已碎
    2021-01-15 09:03

    Top right corner has coordinates w/2, h/2 relative to the center. After rotation its absolute coordinates are

     x = cx + w/2 * Cos(Phi) - h/2 * Sin(Phi)
     y = cy + w/2 * Sin(Phi) + h/2 * Cos(Phi)
    

提交回复
热议问题