明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1109|回复: 6

[基础] 请问tan-1的副程式该怎么写呢

[复制链接]
发表于 2011-5-29 13:56 | 显示全部楼层 |阅读模式
这里有一段副程式(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))))

)


反回值是一个斜率,请问我该如何让斜率变成角度呢??
发表于 2011-5-30 11:38 | 显示全部楼层
(defun rtd (radians)
  (* 180.0 (/ radians pi))
)

(RTD (ATAN TANX))
发表于 2011-5-30 12:39 | 显示全部楼层
atan                                       .
 楼主| 发表于 2011-5-30 20:33 | 显示全部楼层
喔喔,原來lisp中就有atan這個函數了啊。
可惜沒有acos asin
发表于 2011-5-31 16:00 | 显示全部楼层
;;;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))
)
 楼主| 发表于 2011-5-31 18:47 | 显示全部楼层
謝謝你啦,收獲真多。
发表于 2011-5-31 18:50 | 显示全部楼层
lead009 发表于 2011-5-30 20:33
喔喔,原來lisp中就有atan這個函數了啊。
可惜沒有acos asin

http://bbs.mjtd.com/thread-64527-1-1.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-20 21:21 , Processed in 0.574785 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表