Skip to content

[lisp/geo/geopack.l] normalize norm vector in optional arugment of vector-angle function. #262

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lisp/geo/geopack.l
Original file line number Diff line number Diff line change
Expand Up @@ -98,11 +98,13 @@ left hand side of line a-b, and b lies at the right side of ac."
"normal vector for the plane on which three points (a b c) lie."
(normalize-vector (v* (v- b a) (v- c a))))

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

(defun face-normal-vector (vertices)
Expand Down