请问tan-1的副程式该怎么写呢
这里有一段副程式(defun tan(en / data p10 p11 x1 x2 y1 y2);;給en 得tan(setq data(entget en))
(setq p10(cdr(assoc 10 data)))
(setq p11(cdr(assoc 11 data)))
(setq x1(car p10))
(setq x2(car p11))
(setq y1(cadr p10))
(setq y2(cadr p11))
(print p10)
(print p11)
(setq tanx(/ (abs(- y1 y2)) (abs(- x1 x2))))
)
反回值是一个斜率,请问我该如何让斜率变成角度呢??
(defun rtd (radians)
(* 180.0 (/ radians pi))
)
(RTD (ATAN TANX)) atan . 喔喔,原來lisp中就有atan這個函數了啊。
可惜沒有acos asin ;;;The acos function returns the acos of the argument x, a real number between 0 and 1.
;;;Code:
(defun acos (x)
(atan (/ (sqrt (- 1 (* x x))) x))
)
;;;The asin function returns the arcsin of the argument sine, a real number between -1 and 1.
;;;Code:
(defun asin (sine / cosine)
(setq cosine (sqrt (- 1.0 (expt sine 2))))
(if (zerop cosine)
(setq cosine 0.000000000000000000000000000001)
)
(atan (/ sine cosine))
) 謝謝你啦,收獲真多。 lead009 发表于 2011-5-30 20:33 static/image/common/back.gif
喔喔,原來lisp中就有atan這個函數了啊。
可惜沒有acos asin
http://bbs.mjtd.com/thread-64527-1-1.html
页:
[1]