关于顶点计算问题
绘制等腰三角形,以下代码执行不了,烦请大佬帮忙指正哪个地方出错了并给出正确代码,万分感谢(defun c:sanjiaoxing ()
(setq p1 (getpoint "\n指定等腰三角形底边起点"))
(setq p2 (getpoint "\n指定等腰三角形底边终点"))
(setq p3 (getpoint "\n指定顶点方向"))
(if (/= (length p1) 2)
(progn
(princ "\n错误:每个点坐标应为 (x y) 形式。\n")
(princ)
(exit)
)
(if (/= (length p2) 2)
(progn
(princ "\n错误:每个点坐标应为 (x y) 形式。\n")
(princ)
(exit)
)
)
)
(setq midpoint (list (/ (+ (car p1) (car p2)) 2) (/ (+ (cadr p1) (cadr p2)) 2)))
(setq vector-to-p3 (list (- (car p3) (car midpoint)) (- (cadr p3) (cadr midpoint))))
(setq height-approx (cadr vector-to-p3))
(setq vertex (polar midpoint 0 height-approx))
(command "pline" p1 p2 vertex "c")
(princ "\n等腰三角形已绘制。\n")
(princ)
)
(defun c:tt ()
(if (and
(setq p1 (getpoint "\n指定等腰三角形底边起点"))
(setq p2 (getpoint p1"\n指定等腰三角形底边终点"))
(progn
(vl-cmdf "LINE" p1 p2 "")
(setq ent (entlast))
t
)
(setq midpoint (list (/ (+ (car p1) (car p2)) 2)
(/ (+ (cadr p1) (cadr p2)) 2)
)
)
(setq p3 (getpoint midpoint"\n指定顶点方向"))
)
(progn
(entdel ent)
(setq p4 (polar p3 (+ (angle p1 p2) (* pi 0.5)) 100))
(setq p5 (inters p1 p2 p3 p4 nil))
(setq p6 (polar midpoint (angle p5 p3) (distance p3 p5)))
(setvar "OSMODE" 0)
(command "pline" p1 p2 p6 "c")
(princ "\n等腰三角形已绘制。\n")
)
)
(princ)
)
永不言弃 发表于 2024-7-17 08:57
完美,感谢感谢
页:
[1]