三角形内心(角平分线交点)
本帖最后由 newer 于 2014-10-16 16:07 编辑;;三角形内心 (角平分线交点,内切圆圆心)
(defun XD::Geom:Triangleheart (p1 p2 p3 / v1 v12 v13 v2 v21 v23)
(setq v13 (xdrx_vector_normalize (mapcar '- p3 p1))
v12 (xdrx_vector_normalize (mapcar '- p2 p1))
v1 (mapcar '+ v13 v12)
v23 (xdrx_vector_normalize (mapcar '- p3 p2))
v21 (xdrx_vector_normalize (mapcar '- p1 p2))
v2 (mapcar '+ v23 v21)
)
(inters p1 (mapcar '+ p1 v1) p2 (mapcar '+ p2 v2) nil)
)
(defun triangle:heart (p1 p2 p3 / p11 p12 )
(setq p11 (c:cal "pld(p1,p3,abs(p1-p2))")
p22 (c:cal "pld(p3,p2,abs(p1-p3))")
)
(inters p1
(c:cal "(p2+p11)/2")
p3
(c:cal "(p1+p22)/2")
)
) 放到一个表达式
(defun ff (p1 p2 p3)
(inters p1
(c:cal "plt(p2,pld(p1,p3,abs(p1-p2)),0.5)")
p3
(c:cal "(p1+pld(p3,p2,abs(p1-p3)))/2")
)
) st788796 发表于 2014-10-16 21:17
放到一个表达式
如上帖,一次完成
(defun ff (p1 p2 p3)
(c:cal
"ill(p1,plt(p2,pld(p1,p3,abs(p1-p2)),0.5),p3,plt(p1,pld(p3,p2,abs(p1-p3)),0.5))"
)
)
本帖最后由 高山流水 于 2014-10-17 17:10 编辑
求三角形的中心,用角度求解效率可能比较高(当然用向量求解比较通用,可以用于空间)。
(defun triheart(p0 p1 p2 / f)
;; by GSLS(SS) 2014.10.17
(setq f (lambda (p0 p1 p2 / d a a0)
(setq d (distance p0 p1)
a (- (setq a0 (angle p1 p0)) (angle p1 p2)))
(- a0 (/ (angle '(0 0) (list (* d (cos a)) (* d (sin a)))) 2.))))
(inters p1 (polar p1 (f p0 p1 p2) 1000.) p2 (polar p2 (f p1 p2 p0) 1000.) nil))
;; for test
(defun c:test(/ p0 p1 p2 ph)
(setq p0 (getpoint "\nSelect First Point of the triangle :")
p1 (getpoint p0 "\nSelect Second Point of the triangle :")
p2 (getpoint p1 "\nSelect Third Point of the triangle :"))
(if (and p0
p1
p2
(setq ph (triheart p0 p1 p2)))
(entmake (list (cons 0 "Point")
(cons 10 ph)
(cons 62 1))))
(princ))
学习,学习。 谢谢分享!{:1_23:}学习学习。
页:
[1]