gsc Posted February 15, 2018 Posted February 15, 2018 Hi, How can I determine in which quadrant pt2 is relative to pt1? Quote
Tharwat Posted February 15, 2018 Posted February 15, 2018 Hi, You can identify that with the angle value between the two points, so if angle is bigger than 180 and smaller than 270 then you are there. Quote
Aftertouch Posted February 15, 2018 Posted February 15, 2018 Or a X-Y compair. +X +Y = 1st +X -Y = second -X -Y = third -X +Y = fourth Quote
Grrr Posted February 15, 2018 Posted February 15, 2018 Heres something to investigate: _$ (setq p1 '(10. 10. 10.)) (10.0 10.0 10.0) _$ (setq p2 '(5. 13. -4.)) (5.0 13.0 -4.0) _$ (setq p (mapcar '- p2 p1)) (-5.0 3.0 -14.0) _$ (setq res (mapcar 'minusp p)) (T nil T) _$ (setq res (apply '(lambda (a b c) (list a b)) res)) (T nil) ; +X +Y = 1st ; +X -Y = second ; -X -Y = third ; -X +Y = fourth _$ (vl-some '(lambda (x) (if (equal (cdr x) res) (car x))) '( (1st nil nil) (2nd nil T) (3rd T T) (4th T nil) ) ) 4TH Or just use the angle function for the p1 and p2, and determine with cond if its between 0/90/180/270. Quote
lrm Posted February 15, 2018 Posted February 15, 2018 Or... (setq q (fix (+ 1 (/ (angle p1 p2) (/ pi 2))))) Quote
Lee Mac Posted February 15, 2018 Posted February 15, 2018 Another - (defun quadrant ( bpt pnt ) (vl-position (mapcar 'minusp (mapcar '- pnt bpt '(0 0))) '(() (nil nil) (t nil) (t t) (nil t))) ) Quote
Grrr Posted February 15, 2018 Posted February 15, 2018 Another -... Very nice result, Lee! Added to my lib.. Quote
gsc Posted May 14, 2018 Author Posted May 14, 2018 (edited) Hi, the codes of both Lee and Irm return q=3 where it should be q=4 for the folowing 2 coordinats...is this correct? p1 (bpt) = 494487.36,5727352.41 p2 (pnt) = 494497.36,5725787.41 Modified: Sorry miscalculation...codes are correct Edited May 14, 2018 by gsc Quote
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.