VEC 1 =圆心,VEC2 = mousePos结构,找到VEC 1,VEC 2之间的圆点 [英] Vec1 = Circle centre, Vec2 = mousepos, find the point on the circle between Vec1, Vec2

查看:205
本文介绍了VEC 1 =圆心,VEC2 = mousePos结构,找到VEC 1,VEC 2之间的圆点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个矢量:一个是在一个圆的中心,另一个是在鼠标位置。我想找到的圆是两个向量之间的角度。

我特别想在圆心+直径,而不是三角学方面的答案。所以,圆心+圆直径(以方向)鼠标位置。

如果有帮助,认为一个时钟。我需要数的手所指向​​的矢量coordinance。手总是向着变量向量'鼠标的位置指点。

我要'点'(vec2d_X)的上(vec2d_1)在时钟的中心之间的圆圈的和'鼠标的位置(vec2d_2)。

也看到这个跟进的问题:
<一href="http://stackoverflow.com/questions/25925163/determine-rotation-direction-toward-variable-point-on-a-circle">Determine旋转方向/朝一个圆 /可变点

编辑>>>>>>

时使用trig的更快?

  #Python
高清circlepoint_trig(顶点,mousePos结构,circlepoint):
    角= math.atan2(mousePos结构[1]  - 顶点[1],mousePos结构[0]  - 顶点[0])
    MYX = 80 * math.cos(角)#80是时钟'手'的长度
    MYY = 80 * math.sin(角)#80是时钟'手'的长度
    circlepoint = vec2d(MYX,MYY)+顶点
    回报circlepoint
 

解决方案

radius_vector = mouse_position - circle_center

normalized_vector = radius_vector * circle_radius / radius_vector.length()

circle_point = circle_center + normalized_vector

澄清:

vector.length =开方(vector.x * vector.x + vector.y * vector.y)

I have two vectors: one is in the centre of a circle, another is at the mouse position. I want to find the point on the circle that is between the two vectors.

I specifically want the answer in terms of circle centre + diameter, not trigonometry. So, Circle centre + circle diameter (in the direction of) the mouse position.

If it helps, think of a clock. I need the vector coordinance of the 'number' the 'hand' is pointing to. The hand is always pointing toward the variable vector 'mouse position'.

I want 'the point'(vec2d_X) on the circle between the 'centre of the clock' (vec2d_1) and the 'mouse position'(vec2d_2).

See also this follow up question:
Determine rotation direction /toward/ variable point on a circle

EDIT>>>>>>

Is using trig faster?

#Python
def circlepoint_trig(vertex, mousepos, circlepoint):
    angle = math.atan2(mousepos[1] - vertex[1], mousepos[0] - vertex[0])
    myx = 80 * math.cos(angle) #80 is length of clock 'hand'
    myy = 80 * math.sin(angle) #80 is length of clock 'hand'
    circlepoint = vec2d(myx,myy) + vertex
    return circlepoint

解决方案

radius_vector = mouse_position - circle_center

normalized_vector = radius_vector * circle_radius / radius_vector.length()

circle_point = circle_center + normalized_vector

Clarification:

vector.length=sqrt(vector.x*vector.x+vector.y*vector.y)

这篇关于VEC 1 =圆心,VEC2 = mousePos结构,找到VEC 1,VEC 2之间的圆点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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