Math Forums @ Math Goodies
Math Forums @ Math Goodies
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Homework Help Forums
 Algebra
 Vector Alegbra- Direction from three points
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mrajee
New Member

India
2 Posts

Posted - 11/07/2009 :  01:01:33  Show Profile  Reply with Quote
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
Go to Top of Page

Ultraglide
Advanced Member

Canada
113 Posts

Posted - 11/07/2009 :  11:48:51  Show Profile  Reply with Quote
Your code appears to be written in C/C++. Remember that angles are given in radians, not degrees.
Go to Top of Page

mrajee
New Member

India
2 Posts

Posted - 11/08/2009 :  23:03:36  Show Profile  Reply with Quote
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
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
Math Forums @ Math Goodies © 2000-2004 Snitz Communications Go To Top Of Page
This page was generated in 0.53 seconds. Snitz Forums 2000