Aftertouch Posted February 7, 2019 Posted February 7, 2019 Hello all, Got myself into something again... I got a line from point A to point B. There is a block at point C. How can i get the coordinate on that line, perpendicular from the block? lets say.... (setq xy1 (list 1 1 0)) (setq xy2 (list 2 3 0)) (setq xy3 (list 1.5 1.6 0)) (setq xy4 ?????) Quote
Aftertouch Posted February 7, 2019 Author Posted February 7, 2019 Excuse me! Already nailed it with the 'inters' function. Quote
ronjonp Posted February 7, 2019 Posted February 7, 2019 Also look into vlax-curve-getclosestpointto. Quote
Lee Mac Posted February 7, 2019 Posted February 7, 2019 (edited) Alternatively from here: ;; Project Point onto Line - Lee Mac ;; Projects pt onto the line defined by p1,p2 (defun LM:ProjectPointToLine ( pt p1 p2 / nm ) (setq nm (mapcar '- p2 p1) p1 (trans p1 0 nm) pt (trans pt 0 nm) ) (trans (list (car p1) (cadr p1) (caddr pt)) nm 0) ) Which could also be written: (defun LM:projectpointtoline ( pnt pt1 pt2 ) ( (lambda ( vec ) (trans (reverse (cons (caddr (trans pnt 0 vec)) (cdr (reverse (trans pt1 0 vec))))) vec 0)) (mapcar '- pt1 pt2) ) ) For your case: (setq xy1 '(1.0 1.0 0.0) xy2 '(2.0 3.0 0.0) xy3 '(1.5 1.6 0.0) xy4 (LM:projectpointtoline xy3 xy1 xy2) ) Edited February 7, 2019 by Lee Mac 1 Quote
Aftertouch Posted February 8, 2019 Author Posted February 8, 2019 Nice Lee Mac, Ill give it a try. Quote
lee50310 Posted June 23, 2019 Posted June 23, 2019 This program can get the vertical coordinate point xy4 (defun per4 (xy1 xy2 xy3 ) (setq ang (angle xy1 xy2) ptm (polar xy3 (+ (* 0.5 pi) ang) 0.1) xy4 (inters xy1 xy2 xy3 ptm nil) ) ) 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.