Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Arc intersection with line in AutoLisp?

22 REPLIES 22
Reply
Message 1 of 23
BillZ
1741 Views, 22 Replies

Arc intersection with line in AutoLisp?

R14 Autolisp:
You can find an intersection of one line with another using the Inters function. Is there an easy way to find the intersection of an Arc with a line? Any formulas?
Thanks
BillZ
22 REPLIES 22
Message 21 of 23
Anonymous
in reply to: BillZ

Bill,

> BTW: I noticed the last code you posted still only returns one side even
if
> the line intersects twice.

The variable pl either contains (2) point lists when the line intersects
twice, (1) for once or is nil with no intersections. -David
Message 22 of 23
Anonymous
in reply to: BillZ

Well, here is another approach that I wrote back in 1988, it was my first
intents to create a function for line-arc or line-circle intersection
founders.

The one that I use today is way out different, but you can easily changed to
suit your needs.

It will return a list of points even if the line intersect just once you
need to implement the point-is-on-arc method.

Best regards,
Luis Esquivel
ArqCOM Software
www.arqcom.com.mx

Here is de demo...
;;; Usage:
;;; (getlinecir-inters
center> )
;;; Return: List of point or nil
(defun getlinecir-inters (pl1 pl2 cen r / x1 y1 x2 y2 h r2
k yt1 yt2 pt1 pt2 m yk2 xt1 xt2 a b
c z lst1
)
(setq x1 (car pl1)
y1 (cadr pl1)
x2 (car pl2)
y2 (cadr pl2)
r2 (expt r 2)
h (car cen)
xh2 (expt (- x1 h) 2)
k (cadr cen)
)
(if (equal x2 x1 0.0001)
(if (>= r2 xh2)
(setq yt1 (+ (expt (- r2 xh2) 0.5) k)
yt2 (- k (expt (- r2 xh2) 0.5))
pt1 (list x1 yt1)
pt2 (list x1 yt2)
)
)
(progn
(setq m (/ (- y2 y1) (- x2 x1)))
(if (equal m 0 0.0001)
(if (>= r2 (setq yk2 (expt (- y1 k) 2)))
(setq xt1 (+ (sqrt (- r2 yk2)) h)
xt2 (- h (sqrt (- r2 yk2)))
pt1 (list xt1 y2)
pt2 (list xt2 y2)
)
)
(progn
(setq a (+ 1.0 (expt m 2))
b (- (* 2.0 m (- x1 h (* m k))) (* 2.0 y1))
c (+ (expt (+ (* m (- h x1)) y1) 2)
(* (expt m 2) (- (expt k 2) r2))
)
z (- (expt b 2) (* 4 a c))
)
(if (equal z 0 0.0001)
(setq z 0)
)
(if (>= z 0)
(setq yt1 (/ (- (expt z 0.5) b) (* 2.0 a))
yt2 (/ (* -1.0 (+ (expt z 0.5) b)) (* 2.0 a))
xt1 (+ (/ (- yt1 y1) m) x1)
xt2 (+ (/ (- yt2 y1) m) x1)
pt1 (list xt1 yt1)
pt2 (list xt2 yt2)
)
)
)
)
)
)
(if pt1
(setq lst1 (append lst1 (list pt1)))
)
(if pt2
(setq lst1 (append lst1 (list pt2)))
)
lst1
)
Message 23 of 23
BillZ
in reply to: BillZ

Try it again.
BillZ

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

”Boost