### Author Topic: 3 points are clockwise or counter-clockwise?  (Read 1995 times)

0 Members and 1 Guest are viewing this topic.

#### FELIX

• Bull Frog
• Posts: 223
##### 3 points are clockwise or counter-clockwise?
« on: March 23, 2014, 09:43:13 PM »
3 data points PT1, PT2 and PT3 are determining whether clockwise or counterclockwise?
OK.

#### Kerry

• Mesozoic relic
• Seagull
• Posts: 11654
• class keyThumper<T>:ILazy<T>
##### Re: 3 points are clockwise or counter-clockwise?
« Reply #1 on: March 23, 2014, 10:04:10 PM »
Have a play with this (from a site search) :-

http://www.theswamp.org/index.php?topic=13526.msg234360#msg234360
From gile

Code - Auto/Visual Lisp: [Select]
1. ;;; Clockwise-p Evaluates if p1 p2 et p3 are clockwise
2. ;; gile http://www.theswamp.org/index.php?topic=13526.msg234360#msg234360
3.
4. (defun clockwise-p (p1 p2 p3)
5.   (< (sin (- (angle p1 p3) (angle p1 p2))) -1e-14)
6. )
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

--> Donate to theSwamp<--

#### FELIX

• Bull Frog
• Posts: 223
##### Re: 3 points are clockwise or counter-clockwise?
« Reply #2 on: March 23, 2014, 11:05:24 PM »
Very good, thank you so much!
OK.

#### gile

• Water Moccasin
• Posts: 2392
• Marseille, France
##### Re: 3 points are clockwise or counter-clockwise?
« Reply #3 on: March 24, 2014, 02:29:43 AM »
Hi,

Another way using the double signed area of the triangle:

Code - Auto/Visual Lisp: [Select]
1. (defun clockwise-p (p1 p2 p3)
2.     (- (* (- (car p2) (car p1)) (- (cadr p3) (cadr p1)))
3.        (* (- (car p3) (car p1)) (- (cadr p2) (cadr p1)))
4.     )
5.   )
6. )
Speaking English as a French Frog

#### Lee Mac

• Seagull
• Posts: 12696
• London, England
##### Re: 3 points are clockwise or counter-clockwise?
« Reply #4 on: March 24, 2014, 07:17:57 PM »