Author Topic: How to determine a point is on the left of right of Pline  (Read 1511 times)

0 Members and 1 Guest are viewing this topic.

doductiep

  • Mosquito
  • Posts: 8
How to determine a point is on the left of right of Pline
« on: November 17, 2021, 05:05:59 AM »
I have a Point (PT1) and a Pline, always exist a Line accross PT1 and perpendicular with Pline
How to know a Point is on the left or Right of Pline by autolisp?
Please help.
Thank all.

kpblc

  • Bull Frog
  • Posts: 396
Re: How to determine a point is on the left of right of Pline
« Reply #1 on: November 17, 2021, 05:14:32 AM »
No tests
Code - Auto/Visual Lisp: [Select]
  1. (setq pt  (getpoint "\nPoint : ")
  2.       ent (car (entsel "\nPline : "))
  3. ) ;_ end of setq
  4.  
  5. (cond ((< (* pi 0.5) a (* pi 1.5)) "left")
  6.       ((equal a (* pi 0.5) 1e-6) "top")
  7.       ((equal a (* pi 1.5) 1e-6) "bottom")
  8.       (t "right")
  9. ) ;_ end of cond
Sorry for my English.

Lee Mac

  • Seagull
  • Posts: 12906
  • London, England
Re: How to determine a point is on the left of right of Pline
« Reply #2 on: November 17, 2021, 04:50:04 PM »
Consider an expression such as the following:
Code - Auto/Visual Lisp: [Select]
  1. (minusp (sin (- (angle l1 pt) (angle l1 l2))))

Where:
  • pt is the point to be tested
  • l1 & l2 are end points of a line to test against
The expression will return T if the point lies to the left of the line, and nil if on the right.

doductiep

  • Mosquito
  • Posts: 8
Re: How to determine a point is on the left of right of Pline
« Reply #3 on: November 17, 2021, 09:33:08 PM »
No tests
Code - Auto/Visual Lisp: [Select]
  1. (setq pt  (getpoint "\nPoint : ")
  2.       ent (car (entsel "\nPline : "))
  3. ) ;_ end of setq
  4.  
  5. (cond ((< (* pi 0.5) a (* pi 1.5)) "left")
  6.       ((equal a (* pi 0.5) 1e-6) "top")
  7.       ((equal a (* pi 1.5) 1e-6) "bottom")
  8.       (t "right")
  9. ) ;_ end of cond
Consider an expression such as the following:
Code - Auto/Visual Lisp: [Select]
  1. (minusp (sin (- (angle l1 pt) (angle l1 l2))))

Where:
  • pt is the point to be tested
  • l1 & l2 are end points of a line to test against
The expression will return T if the point lies to the left of the line, and nil if on the right.
Thank @kpblc and @Lee Mac

CatDance

  • Newt
  • Posts: 57
Re: How to determine a point is on the left of right of Pline
« Reply #4 on: November 23, 2021, 01:33:50 AM »
Consider an expression such as the following:
Code - Auto/Visual Lisp: [Select]
  1. (minusp (sin (- (angle l1 pt) (angle l1 l2))))

Where:
  • pt is the point to be tested
  • l1 & l2 are end points of a line to test against
The expression will return T if the point lies to the left of the line, and nil if on the right.

Lee Mac, you are a legend in the Autolisp communities. You never fail to impress me.
A must-read book: Amazing story how Bill + Paul started Microsoft and history of computer revolution.
https://www.amazon.com/Hard-Drive-Making-Microsoft-Empire/dp/0887306292

Brief history of Microsoft
https://www.youtube.com/watch?v=BLaMbaVT22E