本帖最后由 夏生生 于 2021-9-14 11:09 编辑
感觉你的算法不对,不过我也不是专业的,您试试
- (defun c:xgx (/ r1 r2 ang n pt x1 i lst x y make-lwpl)
- (setq r1 (getreal "\n主管半径:")
- r2 (getreal "\n支管半径:")
- ang (getangle "\n夹角:")
- n (getint "\n等分数:")
- pt (getpoint "\n插入点:")
- )
- (setq x1 (/ pi (* 0.5 n))
- i 0
- )
- (repeat (1+ n)
- (setq x (* i x1))
- (setq y (/ (+ (* r2 (cos x) (cos ang))
- (sqrt (- (* r1 r1) (expt (* r2 (sin x)) 2)))
- )
- (sin ang)
- )
- )
- (setq i (1+ i)
- lst (cons (list (* r2 x) y) lst)
- )
- )
- (make-lwpl
- (mapcar '(lambda (x)
- (mapcar '+
- (list (car pt) (- (cadr pt) (cadr (last lst))))
- x
- )
- )
- lst
- )
- 0
- 0
- )
- (defun make-lwpl (plist mode w / ocs ed)
- (setq ocs (trans '(0 0 1) 1 0 t))
- (setq ed (list (cons 0 "LWPOLYLINE")
- (cons 100 "AcDbEntity")
- (cons 100 "AcDbPolyline")
- (cons 90 (length plist))
- (cons 70 mode)
- (cons 43 w)
- )
- )
- (foreach elem plist
- (setq
- ed (append ed
- (list (cons 10 (trans elem 1 ocs))
- )
- )
- )
- )
- (setq ed (append ed (list (cons 210 ocs))))
- (entmakex ed)
- )
- )
|