 - (defun ArcStartEndLength (startPoint endPoint arcLength
- / newton chord ang
- rad mid cen
- )
- ;; use the Newton method to compute the arc half angle according to its length and chord
- (defun newton (arc chord / k x)
- (setq k (/ chord arc)
- x (sqrt (- 6 (* 6 k)))
- )
- (repeat 6
- (setq x (- x (/ (- (sin x) (* k x)) (- (cos x) k))))
- )
- )
- (setq chord (distance startPoint endPoint))
- (if (< chord arcLength)
- (progn
- (setq ang (newton arcLength chord)
- rad (abs (/ chord 2. (sin ang)))
- mid (mapcar '(lambda (p1 p2) (/ (+ p1 p2) 2.0))
- startPoint
- endPoint
- )
- )
- (if (equal (/ pi 2) ang 1e-009)
- (setq cen mid
- rad (/ chord 2.)
- )
- (setq
- cen (polar mid
- (+ (angle startPoint endPoint) (/ pi 2))
- (* rad (cos ang))
- )
- )
- )
- (entmakex
- (list
- (cons 0 "ARC")
- (cons 10 cen)
- (cons 40 rad)
- (cons 50 (angle cen startPoint))
- (cons 51 (angle cen endPoint))
- )
- )
- )
- )
- )
- (defun c:tt ()
- (if (and (setq len (getreal "\nArc Length<Quit>:"))
- (setq p1 (getpoint "\nStart point<Quit>:"))
- (setq p2 (getpoint p1 "\nEnd Point<Quit>:"))
- )
- (progn
- (ArcStartEndLength p1 p2 len)
- )
- )
- (princ)
- )
|