确定圆上的旋转方向/朝向/可变点 [英] Determine rotation direction /toward/ variable point on a circle

查看:41
本文介绍了确定圆上的旋转方向/朝向/可变点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给定圆心:vectorA 和圆周长上的另一个 Vector:vectorB,您如何确定 vectorB 转换到圆周长上另一个可变点的较短路径:vectorC?较短的路线是顺时针旋转还是逆时针旋转?

Given circle centre: vectorA and another Vector on the circle's perimeter:vectorB, how can you determine the shorter route for vectorB to translate to another point on the circle's perimeter that is variable:vectorC? Will the shorter route be clockwise or counter clockwise rotation?

如果它有助于想出一个时钟.如果时间是时钟周长上的一个随机点,例如.6,分针位置是已知的,例如.4. 指针是否需要绕时钟中心点顺时针或逆时针旋转才能到达随机点(6)?

If it helps think of a clock. If the times is a random point on the clock's perimeter eg. 6, and the minute hand position is known, eg. 4. Does the hand need to rotate around the clock's centre point clockwise or counter clockwise to reach the random point (6)?

另见:
Vec1 = 圆心,Vec2 = mousepos, 求Vec1, Vec2之间圆上的点

推荐答案

只计算三角形ABC的缠绕方向

所以如果你计算正常的 n=(BA)x(CB) 其中 x 是叉积然后 nz 符号确定方向.

so if you compute normal n=(B-A)x(C-B) where x is cross product then n.z sign determine the direction.

n.z = ((B.x-A.x)*(C.y-B.y)) - ((B.y-A.y)*(C.x-B.x))
if (n.z<0.0) dir=CW else dir=CCW;

这就是你所需要的(CW 表示顺时针和 CCW 逆时针)如果你的坐标系不同,那么可以取消旋转

that is all you need (CW means clockwise and CCW counter clockwise) of coarse if your coordinate system is different then the rotation can be negated

[注释]

if (nz==0) 那么点 B,C 要么相反要么相同所以方向并不重要,因为两种方式的角距离是相同的

if (n.z==0) then the points B,C are either opposite or identical so direction does not matter because both ways the angular distance is the same

这篇关于确定圆上的旋转方向/朝向/可变点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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