From b70b2777b38f2704b1f5eaa134d3413c30351cfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Wed, 12 Dec 2012 20:45:55 +0100 Subject: [PATCH] Using Math::swizzle() in Vector3::cross(). Inspired by http://stackoverflow.com/a/5150625 . --- src/Math/Vector3.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Math/Vector3.h b/src/Math/Vector3.h index 84ff16050..88db8214b 100644 --- a/src/Math/Vector3.h +++ b/src/Math/Vector3.h @@ -20,6 +20,7 @@ */ #include "Vector2.h" +#include "Swizzle.h" namespace Magnum { namespace Math { @@ -98,9 +99,8 @@ template class Vector3: public Vector<3, T> { * @f] */ inline constexpr static Vector3 cross(const Vector3& a, const Vector3& b) { - return Vector3(a[1]*b[2]-a[2]*b[1], - a[2]*b[0]-a[0]*b[2], - a[0]*b[1]-a[1]*b[0]); + return swizzle<'y', 'z', 'x'>(a)*swizzle<'z', 'x', 'y'>(b) - + swizzle<'z', 'x', 'y'>(a)*swizzle<'y', 'z', 'x'>(b); } /** @copydoc Vector::Vector() */