Vec1 = center of the circle, Vec2 = mousepos, find the point on the circle between Vec1, Vec2

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

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

If that helps, think about a watch. I need vectorial coordination of the "number" that the "hand" points to. The hand always points to a variable vector "mouse position".

I want a “point” (vec2d_X) on the circle between the “center of the clock” (vec2d_1) and the “mouse position” (vec2d_2).

See also the following question:
Determine the direction of rotation / direction / variable point on the circle

EDIT → → →

Is a trigger used 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
0
source share
1 answer

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)

+1
source

All Articles