判断v4是否在两个向量中间夹着的范围.
应该是点积啊,怎么会是叉积呢.
https://www.cnblogs.com/JJBox/p/14300098.html#_label1
求得v2->v4落在向量a,向量b,同时大于0,就是夹角范围内了.
如果同时小于0,就是蝴蝶状.
这是我的思路,测试成功了,很庞大.有大佬简化一下吗?
(defun c:tt(/ p1 p2 p4 pt a b mid pa pb)
;;三点夹角(来自大佬xyp1964)
(defun included_angle(p1 pt p3 / ang)
(setq ang (- (angle pt p3) (angle pt p1)))
(if (< ang 0)
(setq ang (+ (* 2.0 pi) ang)))
(if (> ang pi)
(setq ang (- (* 2.0 pi) ang)))
ang
)
;;;取二点的中点
(defun lt:midpoint (p1 p2) (mapcar '(lambda (x y) (/ (+ x y) 2.0)) p1 p2))
;;;主程序
(setq p1(getpoint "\n指定线上点1:")
pt (getpoint p1 "\n指定角点:")
p2(getpoint pt "\n指定线上点2:")
p4(getpoint "\n指定活动点:")
pa (polar pt (angle pt p1) 100)
pb (polar pt (angle pt p2) 100)
a (/ (included_angle p1 pt p2) 2)
mid(lt:midpoint pa pb)
b (included_angle mid pt p4))
(cond
((equal b a 0.001) (princ "\n活动点在线上!"))
((> b a) (princ "\n活动点在角外!"))
((< b a) (princ "\n活动点在角内!"))
)
(princ)
)
`中微子 发表于 2024-6-25 01:20
这是我的思路,测试成功了,很庞大.有大佬简化一下吗?
(defun c:tt(/ p1 p2 p4 pt a b mid pa pb)
没有点积快
页:
1
[2]