旋转后查找点的新坐标 [英] Find new coordinates of a point after rotation

查看:82
本文介绍了旋转后查找点的新坐标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有一个尺寸为w * h的矩形,并且让该矩形内的任意位置(x,y)处有一个任意点,现在我将该矩形旋转到X度,那么该任意位置的新位置是什么旋转后指向.

Suppose i have a rectangle of dimension w*h , and let there is an arbitrary point inside this rectangle at position (x,y) , now i rotate this rectangle to X degree, What will be the new position of that arbitrary point after rotation..

推荐答案

新坐标(x',y')是标准旋转公式的结果:

The new coordinate (x',y') is a result of the standard rotation formula:

y' = y*cos(a) - x*sin(a)
x' = y*sin(a) + x*cos(a)

其中,a是顺时针旋转的角度.假设(x,y)是相对于旋转中心给出的.换句话说,(0,0)是旋转中心.

where a is the angle of a clockwise rotation. This assumes the (x,y) is given with respect to the center of rotation. In other words, (0,0) is the center of rotation.

大多数sin/cos函数要求角度以弧度为单位.在这种情况下,如果X以度为单位,请使用以下转换公式:

Most sin/cos functions require the angle to be in radians. In that case, use this conversion formula if X is in degrees:

a = X * pi / 180

这篇关于旋转后查找点的新坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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