(defun ang_between (p10 p11 p20 p21 / px p1 p2 l_pt l_d p ang)
(setq px (inters p10 p11 p20 p21 nil))
(cond
(px
(if (> (distance px p10) (distance px p11)) (setq p1 p10) (setq p1 p11))
(if (> (distance px p20) (distance px p21)) (setq p2 p20) (setq p2 p21))
(setq
l_pt (list px p1 p2)
l_d (mapcar 'distance l_pt (append (cdr l_pt) (list (car l_pt))))
p (/ (apply '+ l_d) 2.0)
ang (* (atan (sqrt (/ (* (- p (car l_d)) (- p (caddr l_d))) (* p (- p (cadr l_d)))))) 2.0)
)
)
(T
nil
)
)
)
(defun c:divpar ( / pt1 pt2 pt3 pt4 S1 ang1 ang2 x1 x2 ptx1 ptx2)
(setq pt1 (getpoint "\nFirst point of baseline: "))
(setq pt2 (getpoint pt1 "\nSecond point of baseline: "))
(setq pt3 (getpoint pt1 "\nPoint of first adjacent side: "))
(setq pt4 (getpoint pt2 "\nPoint of second adjacent side: "))
(setq S1 (getreal "\nWanted area: "))
(setq ang1 (ang_between pt1 pt2 pt1 pt3))
(setq ang2 (ang_between pt2 pt1 pt2 pt4))
(setq ang1 (- pi ang1) ang2 (- pi ang2))
(setq x1
(*
(/
(* (distance pt1 pt2) (sin ang1))
(sin (+ ang1 ang2))
)
(1-
(+ ;or can be "-"
(sqrt
(1+
(/
(* 2.0 S1 (sin (+ ang1 ang2)))
(* (distance pt1 pt2) (distance pt1 pt2) (sin ang1) (sin ang2))
)
)
)
)
)
)
)
(setq x2 (/ (* x1 (sin ang2)) (sin ang1)))
(setq ptx1 (polar pt1 (angle pt1 pt3) x2))
(setq ptx2 (polar pt2 (angle pt2 pt4) x1))
(command "_.line" "_none" ptx1 "_none" ptx2 "")
)
No comments:
Post a Comment