math - How to find the orientation of three points in a two dimensional space given coordinates of those points? -
actually found formula, dont know how works.
let p,q
, r
3 points,
k=(q.y - p.y)*(r.x - q.x)-(q.x - p.x) * (r.y - q.y); if(k==0): colinear if(k>0) : clockwise if(k<0) : counter clockwise
i pleased if explains how works.
this formula used calculate cross product of vectors q-p , q-r. can see in geometric meaning section cross product value c = x b = |a|*|b|*sin(theta), theta angle between these vectors (point-to-point directions). sin(theta) = 0 parallel vectors, positive when theta < 180, negative otherwise.
example:
clockwise triplet abc: cross product of ab , ac vectors >0
anticlockwise triplet acd: cross product of ac , ad negative.
Comments
Post a Comment