diff --git a/CHANGELOG.md b/CHANGELOG.md index 8344a074f2b0..7a3c5b95b75d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -76,6 +76,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 * Fixed a bug when printing an empty `Tree`. * Fixed a bug in `Group` for IronPython where the decoding declaration was missing. * Fixed a bug where a `Group` without name could not be added to the scene. +* Fixed a bug where `angle_vectors_projected` returned a 0 when an input vector was parallel to projection normal. Now returns `None`. ### Removed diff --git a/src/compas/geometry/_core/angles.py b/src/compas/geometry/_core/angles.py index c10835d08c9f..b95c1f9c25a5 100644 --- a/src/compas/geometry/_core/angles.py +++ b/src/compas/geometry/_core/angles.py @@ -155,6 +155,9 @@ def angle_vectors_projected(u, v, normal, deg=False, tol=None): u_cross = cross_vectors(u, normal) v_cross = cross_vectors(v, normal) + if TOL.is_allclose(u_cross, [0.0, 0.0, 0.0]) or TOL.is_allclose(v_cross, [0.0, 0.0, 0.0]): + raise ValueError("Cannot compute angle between vectors projected onto a plane defined by the normal vector. One of the vectors is parallel to the normal vector.") + return angle_vectors_signed(u_cross, v_cross, normal, deg, tol)