Skip to content

Commit 7f491ef

Browse files
committed
[lisp/geo/geopack.l] check whether v1 and v2 is parallel in vector-angle.
1 parent efd0371 commit 7f491ef

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lisp/geo/geopack.l

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ left hand side of line a-b, and b lies at the right side of ac."
9898
"normal vector for the plane on which three points (a b c) lie."
9999
(normalize-vector (v* (v- b a) (v- c a))))
100100

101-
(defun vector-angle (v1 v2 &optional (normal (normalize-vector (v* v1 v2))))
101+
(defun vector-angle (v1 v2 &optional (normal (normalize-vector (v* v1 v2))) (parallel-thre 1e-10))
102102
"Compute angle (radian) between two vectors, v1 and v2.
103103
Normal is vertical to both v1 and v2.
104104
v1, v2 and normal must be normalized in advance.
105105
Normal must be given if the sign of the angle is needed."
106+
(if (< (norm2 (v* v1 v2)) parallel-thre)
107+
(return-from vector-angle (if (> (v. v1 v2) 0) 0.0 pi)))
106108
(atan (v.* normal v1 v2) (v. v1 v2)) )
107109

108110
(defun face-normal-vector (vertices)

0 commit comments

Comments
 (0)