Determine rotation direction /toward/ variable point on a circle

后端 未结 1 928
陌清茗
陌清茗 2021-01-26 03:10

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 circ

相关标签:
1条回答
  • 2021-01-26 03:51

    Just compute winding direction of triangle ABC

    circle point dir

    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;
    

    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

    [Notes]

    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

    0 讨论(0)
提交回复
热议问题