samifox Posted October 11, 2018 Share Posted October 11, 2018 hi a few years ago Lee Mac posted a simple mathematic function to easily detect 90-degree corners in a polyline. does anybody know? Thanks Shay Quote Link to comment Share on other sites More sharing options...
Tharwat Posted October 11, 2018 Share Posted October 11, 2018 Hi, Try this one: (defun angle90 (p1 p2 p3) (vl-some '(lambda (ang) (equal (abs (- (angle p1 p2) (angle p2 p3))) ang 1e-4)) (list (* pi 0.5) (* pi 1.5) (+ pi pi)) ) ) (defun c:test ( / 1p 2p 3p ) (and (setq 1p (getpoint "\n1st point :")) (setq 2p (getpoint "\n2nd point :" 1p)) (setq 3p (getpoint "\n3rd point :" 2p)) (alert (strcat "Angle is " (if (angle90 1p 2p 3p) "" "NOT") "equal to 90 Deg."))) (princ)) Quote Link to comment Share on other sites More sharing options...
samifox Posted October 11, 2018 Author Share Posted October 11, 2018 49 minutes ago, Tharwat said: Hi, Try this one: (defun angle90 (p1 p2 p3) (vl-some '(lambda (ang) (equal (abs (- (angle p1 p2) (angle p2 p3))) ang 1e-4)) (list (* pi 0.5) (* pi 1.5) (+ pi pi)) ) ) (defun c:test ( / 1p 2p 3p ) (and (setq 1p (getpoint "\n1st point :")) (setq 2p (getpoint "\n2nd point :" 1p)) (setq 3p (getpoint "\n3rd point :" 2p)) (alert (strcat "Angle is " (if (angle90 1p 2p 3p) "" "NOT") "equal to 90 Deg."))) (princ)) Thank you sir i remember much simpler approach (involve sin cos or tan) PO i really like your plumbing app, there is no price thou) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted October 11, 2018 Share Posted October 11, 2018 1 minute ago, samifox said: Thank you sir i remember much simpler approach (involve sin cos or tan) PO i really like your plumbing app, there is no price thou) You're welcome. If you already installed my Drainage Program then just hit the button Activate to know the price and the activation process but you can message me for more info. Quote Link to comment Share on other sites More sharing options...
rlx Posted October 11, 2018 Share Posted October 11, 2018 maybe google 'visual lisp angle between vertices' https://www.theswamp.org/index.php?topic=41621.0 Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 11, 2018 Share Posted October 11, 2018 Use Lee's code then maybe this? (equal 0. (rem ang (/ pi 2.)) 1e-8) Quote Link to comment Share on other sites More sharing options...
samifox Posted October 12, 2018 Author Share Posted October 12, 2018 16 hours ago, ronjonp said: (equal 0. (rem ang (/ pi 2.)) 1e-8) THamks Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 12, 2018 Share Posted October 12, 2018 6 hours ago, samifox said: THamks You're welcome Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted October 12, 2018 Share Posted October 12, 2018 On 10/11/2018 at 4:48 PM, ronjonp said: Use Lee's code then maybe this? (equal 0. (rem ang (/ pi 2.)) 1e-8) This will also report True for 0 and pi. Maybe (equal (cos ang) 0 1e-8) For 3d polylines or rotated 2d polylines, the angle in p2, formed by 3 points p1, p2 and p3, is 90deg if the dot product of the vectors p2-p1 and p2-p3 is 0.0. ;dot product (defun uxv (u v) (apply '+ (mapcar '* u v))) (setq u (mapcar '- p1 p2) v (mapcar '- p3 p2) ) (equal 0.0 (uxv u v) 1e-8) Quote Link to comment Share on other sites More sharing options...
ronjonp Posted October 12, 2018 Share Posted October 12, 2018 2 minutes ago, Stefan BMR said: This will also report True for 0 and pi. Oops Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.