lead009 发表于 2011-5-29 13:56:51

请问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))))

)


反回值是一个斜率,请问我该如何让斜率变成角度呢??

yoyoho 发表于 2011-5-30 11:38:02

(defun rtd (radians)
(* 180.0 (/ radians pi))
)

(RTD (ATAN TANX))

zml84 发表于 2011-5-30 12:39:31

atan                                       .

lead009 发表于 2011-5-30 20:33:23

喔喔,原來lisp中就有atan這個函數了啊。
可惜沒有acos asin

yoyoho 发表于 2011-5-31 16:00:20

;;;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-31 18:47:01

謝謝你啦,收獲真多。

zml84 发表于 2011-5-31 18:50:57

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]
查看完整版本: 请问tan-1的副程式该怎么写呢