| Author |
Topic  |
|
|
mrajee
Average Member
India
7 Posts |
Posted - 11/07/2009 : 01:01:33
|
Hi, I want to find the direction of the arc drawn from three points for programming purpose. Depending on Point2 I have to decide whether to draw clock wise or counterclock wise arc from Point1 to Point3 through Point2.
My Logic is working in most cases except one case. Sorry: Since i have no provision to attachement image i have explained.
In this case when Point3 is just above Point1 and not horizontal to Point1, Arc is drawn clockwise without passing through Point2.
Point1= P1 =(P1X,P1Y) Point2= P2 =(P2X,P2Y) Point3= P3 =(P3X,P3Y) CenterPoint of Arc C(CX,CY) - I am calculating center from three points
P1P3angle = Angle from Point1 to Point3 P1P2angle = Angle from Point1 to Point2 diff = p1p3angle - p1p2angle;
by Default: Direction = CounterClockwise if (diff < 0 || diff > 180) { Direction = Clockwise } if (p1p3angle == 0) { if (AngleDifference < -180) Direction = CounterClockwise else Direction = Clockwise } if (p1p3angle == 90) { if (diff< -180) Direction = CounterClockwise }
In the mention case above, diff angle is < 0 so , it is updated as Clockwise direction instead of Counterclockwise direction.
Kindly do give soln to overcome the problem |
Edited by - mrajee on 11/07/2009 02:02:25 |
 |
|
|
Ultraglide
Advanced Member
Canada
164 Posts |
Posted - 11/07/2009 : 11:48:51
|
| Your code appears to be written in C/C++. Remember that angles are given in radians, not degrees. |
 |
|
|
mrajee
Average Member
India
7 Posts |
Posted - 11/08/2009 : 23:03:36
|
quote: Originally posted by Ultraglide
Your code appears to be written in C/C++. Remember that angles are given in radians, not degrees.
Thank you for your reply.But if I change my angle to radian also, the same error occurs.Can you please provide any other method to determine direction of point1, point2 and pont3 in order.
My logic works except for a single case alone |
Edited by - mrajee on 11/09/2009 00:52:58 |
 |
|
| |
Topic  |
|
|
|