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

0 Members and 1 Guest are viewing this topic.

FELIX

  • Bull Frog
  • Posts: 241
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. )
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

FELIX

  • Bull Frog
  • Posts: 241
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

  • Gator
  • Posts: 2507
  • 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.   (minusp
  3.     (- (* (- (car p2) (car p1)) (- (cadr p3) (cadr p1)))
  4.        (* (- (car p3) (car p1)) (- (cadr p2) (cadr p1)))
  5.     )
  6.   )
  7. )
Speaking English as a French Frog

Lee Mac

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