Jump to content

Circle, 2 Points, Along Axis of 2 Points - How to Orient?


Recommended Posts

Posted

I am trying to do a lisp routine  where I click on two points.  The center of the circle is on the first point and has a fixed radius or diameter.  The circle has as its axis an imaginary line between the two points.

 

Getting the two points is easy enough, but how do I orient the circle along the imaginary line?  The two points will be typically non-orthagonal (I don't know if that makes a difference though).

 

Greg

Posted

A before and after pic/dwg would help.

Posted
7 hours ago, GregGleason said:

I am trying to do a lisp routine  where I click on two points.  The center of the circle is on the first point and has a fixed radius or diameter.  The circle has as its axis an imaginary line between the two points.

 

Getting the two points is easy enough, but how do I orient the circle along the imaginary line?  The two points will be typically non-orthagonal (I don't know if that makes a difference though).

 

Greg

 

 

Should "The circle has as its axis an imaginary line between the two points" be interpreted to mean that the circle lies on a plane perpendicular to the line defined by the two points?  

Posted
2 hours ago, lrm said:

 

 

Should "The circle has as its axis an imaginary line between the two points" be interpreted to mean that the circle lies on a plane perpendicular to the line defined by the two points?  

 

Yes.  I should have been more clear, but that is it exactly.

Greg

Posted
10 hours ago, ronjonp said:

A before and after pic/dwg would help.

image.thumb.png.a0445949a0b6d7486acff6fe4524192a.png

 

Here is a 4-view that is an "after".  Upper left is top.  Upper right is right, lower left is front, and lower right is isometric 1.  The green line represents two points.

Greg

Posted (edited)

Like this?

 

(defun c:foo ( / nrm p1 p2 rad)
    (and
	(setq rad 10)	; Can be modified to getdist if desired, or else this will do
	(setq p1 (getpoint "\nSpecify first point <exit>: "))
	(setq p2 (getpoint p1 "\nSpecify second point <exit>: "))
	(progn
	    (setq p1 (trans p1 1 0)
		  p2 (trans p2 1 0)
		  nrm (vx1 (mapcar '- p2 p1))
		  )
	    (entmake
		(list
		    '(0 . "LINE")
		    (cons 10 p1)
		    (cons 11 p2)
		    )
		)
	    (entmake
		(list
		    '(0 . "CIRCLE")
		    (cons 10 (trans p1 0 nrm))
		    (cons 40 rad)
		    (cons 210 nrm)
		    )
		)
	    )
	)
    )

;; Unit Vector  -  Lee Mac
;; Args: v - vector in R^2 or R^3

(defun vx1 ( v )
    (   (lambda ( n ) (if (equal 0.0 n 1e-10) nil (mapcar '/ v (list n n n))))
        (distance '(0.0 0.0 0.0) v)
    )
)

 

Edited by Jonathan Handojo
Posted
6 hours ago, Jonathan Handojo said:

Like this?

 


(defun c:foo ( / nrm p1 p2 rad)
    (and
	(setq rad 10)	; Can be modified to getdist if desired, or else this will do
	(setq p1 (getpoint "\nSpecify first point <exit>: "))
	(setq p2 (getpoint p1 "\nSpecify second point <exit>: "))
	(progn
	    (setq p1 (trans p1 1 0)
		  p2 (trans p2 1 0)
		  nrm (mapcar '- p2 p1)
		  )
	    (entmake
		(list
		    '(0 . "LINE")
		    (cons 10 p1)
		    (cons 11 p2)
		    )
		)
	    (entmake
		(list
		    '(0 . "CIRCLE")
		    (cons 10 (trans p1 '(0.0 0.0 1.0) (vx1 nrm)))
		    (cons 40 rad)
		    (cons 210 nrm)
		    )
		)
	    )
	)
    )

;; Unit Vector  -  Lee Mac
;; Args: v - vector in R^2 or R^3

(defun vx1 ( v )
    (   (lambda ( n ) (if (equal 0.0 n 1e-10) nil (mapcar '/ v (list n n n))))
        (distance '(0.0 0.0 0.0) v)
    )
)

 

 

Thank you Jonathan Handojo!  That is what I was shooting for!  I need to study the Unit Vector by Lee Mac to see if I can get an understanding of how this works.  Truly amazing solve and I appreciate it!

 

Greg

Posted

The Cal function NOR may be useful, "Calculating a Normal Vector", nor(p1,p2)

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

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