AutoCAD LISP利用一顶点和三边长绘制三角形,代码如下。
(defun c:test()
(setq pointa (getpoint "请输入左下角点:"))
(setq A (getreal "\n请输入底边长:"))
(setq B (getreal "\n请输入左下角点对边长:"))
(setq C (getreal "\n请输入第三边长:"))
(setq pointb (polar pointa 0 a))
(setq pointh (polar pointa 0 (/ a 2)))
(setq s (/ (+ a b c) 2))
(setq area (sqrt (* s (- s a) (- s b) (- s c))))
(setq pointc (polar pointh (/ pi 2) (/ (* 2 area) a)))
(command "line" pointa pointb pointc "c")
)
代码完。