本帖最后由 edata 于 2013-12-1 21:52 编辑
 - (defun c:tt(/ pt1 a b c qq s h d jj pt2 pt3);局部变量要设置
- (setq pt1 (getpoint "\n请指定三角形在屏幕中的位置:"))
- (setq a (getreal "\n请输入三角形第一条边长:"))
- (setq b (getreal "\n请输入三角形第二条边长:"))
- (setq c (getreal "\n请输入三角形第三条边长:"))
- (if (and pt1 a b c (> (+ a b ) c)(< (- a b) c))(princ "\n是三角形")(princ "\n不是三角形"));判断方式一
- (if (and pt1 a b c (> (+ b c) a)(> (+ a c) b)(> (+ a b) c) );判断方式二
- (progn
- (setq qq (/ (+ a b c) 2.0))
- (setq s (sqrt (* qq (- qq a) (- qq b) (- qq c))))
- (setq h (/ (* s 2.0) c))
- (setq d (sqrt (- (* b b) (* h h))))
- (setq jj (atan (/ h d)))
- (setq pt2 (polar pt1 0.0 c))
- (setq pt3 (polar pt1 jj b))
- (command "pline" "non" pt1 "non" pt2 "non" pt3 "c" );指定点的时候加"non"是临时取消捕捉,避免因为捕捉造成绘图失败
- )
- (cond ;判断那一个输入值出错的一种方式
- ((null pt1)(princ "\n未指定点"))
- ((or (null a)(null b)(null c ))(princ "\n未输入边长"))
- (t (princ "\n不是三角形"))
- )
- )
- (princ)
- )
|