Browse Source

Using Math::swizzle() in Vector3::cross().

Inspired by http://stackoverflow.com/a/5150625 .
pull/7/head
Vladimír Vondruš 14 years ago
parent
commit
b70b2777b3
  1. 6
      src/Math/Vector3.h

6
src/Math/Vector3.h

@ -20,6 +20,7 @@
*/
#include "Vector2.h"
#include "Swizzle.h"
namespace Magnum { namespace Math {
@ -98,9 +99,8 @@ template<class T> class Vector3: public Vector<3, T> {
* @f]
*/
inline constexpr static Vector3<T> cross(const Vector3<T>& a, const Vector3<T>& b) {
return Vector3<T>(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() */

Loading…
Cancel
Save