0

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?

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)?

See also:
Vec1 = Circle centre, Vec2 = mousepos, find the point on the circle between Vec1, Vec2

Community
  • 1
  • 1

1 Answers1

3

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

Community
  • 1
  • 1
Spektre
  • 49,595
  • 11
  • 110
  • 380
  • I'm not sure what n or z are or why you are using dot notation. Neither are on your diagram. – CodeHard_or_HardCode Sep 21 '14 at 23:50
  • I'm not sure what you mean when you say compute 'winding direction'. What is winding direction and how do you compute that? Are you rotating the triangle? – CodeHard_or_HardCode Sep 21 '14 at 23:55
  • @CodeHard_or_HardCode you obviously lack the vector math applications in vector CG knowledge. polygon winding is the order of points of 2D polygon CW or CCW so if you handle your 2 points and the circle center as triangle and compute the winding then you know if the next point is CW or CCW on circle which is what you want. the winding is computed simple by taking normal vector (crossproduct of 2 wertices of polygon in the order as the polygon is defined) to polygon and taking the sign of its z coordinate. the `n.z` notation is simple access to `z` coordinate of vector `n` – Spektre Sep 22 '14 at 08:04
  • @CodeHard_or_HardCode on image you have 2 points C one for CW case (red) and one for CCW case (magenta) if you compute n.z then you will see magenta is positive and red is negative. – Spektre Sep 22 '14 at 08:07