Jump to content
Aftertouch

Perpendicular coordinate from block to line

Recommended Posts

Aftertouch

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 ?????)

 

image.png.5aac03491418780ae79b7b1030c8309f.png

Share this post


Link to post
Share on other sites
Aftertouch

Excuse me!

Already nailed it with the 'inters' function. 🙂

Share this post


Link to post
Share on other sites
Lee Mac

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 by Lee Mac

Share this post


Link to post
Share on other sites
Aftertouch

Nice Lee Mac,

 

Ill give it a try. 🙂

Share this post


Link to post
Share on other sites
lee50310

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)	
     )     
)

 

Share this post


Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...