From ca2993cadcd864aa4949cfb445b1f38954a861e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Sun, 30 Sep 2012 02:05:40 +0200 Subject: [PATCH] Don't compute sine and cosine more times than necessary. --- src/Math/Matrix3.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Math/Matrix3.h b/src/Math/Matrix3.h index 284425446..7be868204 100644 --- a/src/Math/Matrix3.h +++ b/src/Math/Matrix3.h @@ -72,9 +72,12 @@ template class Matrix3: public Matrix<3, T> { * rad() */ static Matrix3 rotation(T angle) { + T sine = std::sin(angle); + T cosine = std::cos(angle); + return Matrix3( /* Column-major! */ - T(cos(angle)), T(sin(angle)), T(0), - -T(sin(angle)), T(cos(angle)), T(0), + cosine, sine, T(0), + -sine, cosine, T(0), T(0), T(0), T(1) ); }