- 积分
- 8943
- 明经币
- 个
- 注册时间
- 2006-1-10
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
发表于 2014-5-11 14:23:02
|
显示全部楼层
设AB长度为d,弧长AB为L,园心角为2a,则L=2Ra,sina=d/2R,最后方程为sina=a*(d/L),这个方程我不会解,只能求近似值,想到高数中的牛顿迭代法。
(defun c:test( / pta ptb d c l fun fun_ Nd arccos r mid ang d1 d2 pt1 pt2);牛顿迭代法求sinx=x*C,c=d/L,已知两定点与弧长求园弧。
(setq pta (getpoint "\n请输入A点坐标:")
ptb (getpoint pta "\n请输入B点坐标:")
)
(command "_.line" pta ptb "")
(setq d (distance pta ptb))
(while (< l d) (setq L (getreal (strcat "\n请输入弧长\(>" (rtos d 2 2) "\):"))))
(setq c (/ d l))
(defun fun(x) (- (sin x) (* c x)));原函数y=sinx-cx
(defun fun_(x) (- (cos x) c));导函数y=cosx-c
(defun Nd(x) (- x (* (fun x) (fun_ x))));牛顿迭代函数
(defun arccos(x) (atan (/ (sqrt (- 1 (* x x))) x)))
(setq x0 (arccos c))
(setq x0 (* x0 1.5))
(while (not (equal (Nd x0) x0 0.00000001)) (setq x0 (Nd x0)))
(setq r (/ l x0 2)
mid (mapcar '* (mapcar '+ pta ptb) (list 0.5 0.5 0.5))
ang (angle pta ptb)
d1 (* r (cos x0))
d2 (- r d1)
pt1 (polar mid (+ ang (* pi 0.5)) d1)
pt2 (polar mid (+ ang (* pi 1.5)) d2)
)
(command "_.line" pt1 pt2 "")
(command "_.arc" pta pt2 ptb)
) |
|