Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

clockwise check

Status
Not open for further replies.

PZ

Programmer
Jul 21, 2000
18
IT
I need a &quot;something&quot; (sub or function, whatever!) that checks if 3 cartesian points of a triangle in a 2D space are clockwise or counter-clockwise.<br><br>Thanx :D <p> Alex<br><a href=mailto:pizzapz@libero.it>pizzapz@libero.it</a><br><a href= > </a><br>*** Q(uick)BASIC RULEZ! :D***
 
Three points are counter-clockwise if and only if when you rotate them to make the leftmost point point #3, the following is true:

(y2 - y3) / (x2 - x3) > (y1 - y3) / (x1 - x3)

You will need to make special cases for when multiple points have the same X coordinate. If all 3 are colinear then the result is undefined, obviously. These expressions (to the left & right of the inequality operator) are nothing more than slope calculations.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top