From 87f4fc46c294177aa0e79b97ca74688d0287028c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 30 Nov 2016 15:52:14 +0100 Subject: [PATCH] Math: simplify the distance math. Sum of all components of a component-wise vector multiplication is, in fact, a dot product. --- src/Magnum/Math/Geometry/Distance.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Magnum/Math/Geometry/Distance.h b/src/Magnum/Math/Geometry/Distance.h index 634a0c69a..cacf5f836 100644 --- a/src/Magnum/Math/Geometry/Distance.h +++ b/src/Magnum/Math/Geometry/Distance.h @@ -170,7 +170,7 @@ class Distance { * * The distance **d** is computed from point **p** and plane with * normal **n** and **w** using: @f[ - * d = \frac{\sum_i^3 (p \cdot n) + w}{\left| n \right|} + * d = \frac{p \cdot n + w}{\left| n \right|} * @f] * The distance is negative if the point lies behind the plane. * @@ -188,7 +188,7 @@ class Distance { * * The distance **d** is computed from point **p** and plane with * normal **n** and **w** using: @f[ - * d = \sum_i^3 (p \cdot n) + w + * d = p \cdot n + w * @f] * The distance is negative if the point lies behind the plane. * @@ -198,7 +198,7 @@ class Distance { * @see @ref pointPlaneNormalized() */ template static T pointPlaneScaled(const Vector3& point, const Vector4& plane) { - return (plane.xyz()*point).sum() + plane.w(); + return Math::dot(plane.xyz(), point) + plane.w(); } /** @@ -206,7 +206,7 @@ class Distance { * * The distance **d** is computed from point **p** and plane with * normal **n** and **w** using: @f[ - * d = \sum_i^3 (p \cdot n) + w + * d = p \cdot n + w * @f] * The distance is negative if the point lies behind the plane. Expects * that @p plane normal is normalized.