Hi Len,
re:
> For the algorithm you suggested, I'm thinking maybe I could take the entry angle (tangent of the first point I think)
> and rotate the mid and end points to align with cartesian before doing the calculation.
The property of clockwise/counter-clockwise direction is invariant to 2D rotation.
It looks like you have a typo in the isClockwise2() function.
You have this:
code:
function isClockwise2(k,l,m)
{
var XLK = l.x - k.x;
var XMK = m.x - k.x;
>>> var YLK = m.y - k.y; <<<
var YMK = m.y - k.y;
signed_area = 0.5 * (( XLK*YMK ) - ( XMK*YLK ));
if( signed_area > 0)
return 1;
else if( signed_area < 0)
return -1;
else
return 0;
}
There is a typo in the line marked with >>> <<< , it should be
(from http://moi3d.com/forum/index.php?webtag=MOI&msg=11521.42):
code:
var YLK = l.y - k.y;
- Michael
|