在给定其中心点和旋转的情况下查找旋转矩形的角 [英] Find corners of a rotated rectangle given its center point and rotation

查看:104
本文介绍了在给定其中心点和旋转的情况下查找旋转矩形的角的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我知道矩形的中心点(在全局坐标空间中),宽度和高度以及围绕该中心点的旋转,是否有人可以给我找到一个算法来查找矩形的所有四个角?

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 rotation around that center point?

说明 我指的宽度和高度是矩形边的长度.

clarification edit: The width and height I am referring to is the length of the sides of the rectangle.

推荐答案

右上角相对于中心的坐标为w/2,h/2.旋转后,其绝对坐标为

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)

这篇关于在给定其中心点和旋转的情况下查找旋转矩形的角的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆