获取矩形的旋转中心 [英] Get rotation center of rectangle

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

问题描述

给定矩形的边界框,相对旋转中心和旋转角度,我需要找到矩形的绝对旋转中心。这是一张图片(如果有人改进的话,我不介意):

我希望这很清楚。我需要红点的x和y坐标。我一直在研究这个问题已经有一段时间了,我迷失了对trig的琐碎知识。 :/

Given the bounding box, relative rotation center, and rotation angle of a rectangle I need to find the absolute rotation center of the rectangle. Here is an image (I wouldn't mind if someone improved it): I hope that is clear enough. I need the x and y coordinates of the red dot. I've been working on this for some time now and I am lost with my trivial knowledge of trig. :/

推荐答案

如果旋转角度 a 显示为负值以上,那么红点的坐标是:

If the angle of rotation is a shown negative above, then the coordinates of the red dot are:

rx = x + rcx*COS(a) - rcy*SIN(a)
ry = y - (w-rcx)*SIN(a) + rcy*COS(a)

并记住在获取 SIN() COS()之前将度数转换为弧度。

and remember to convert degrees to radians before taking SIN() or COS().

示例:(x,y)=(80,60)(w,h )=(20,60) a = -15°(rcx,rcy)=(15, 30)

rx = 80 + 15*COS(-15°)-30*SIN(-15°)      = 102.25
ry = 60 - (20-15)*SIN(-15°)+30*COS(-15°) = 90.27

以下是GeoGebra的计算结果(负 y -axis)

Here is an output from GeoGebra of the calculation (with negative y-axis)

这篇关于获取矩形的旋转中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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