From d91158656c26571e00b70137e2f1b78fae6c9820 Mon Sep 17 00:00:00 2001 From: Simon Ruesch Date: Tue, 1 Dec 2015 23:19:24 +0100 Subject: [PATCH 1/2] - added static_cast to normalize to remove conversion warning. -added default size = 3 to free function cross, such that vmml::cross(a, b) is possible instead of vmml::cross<3>(a, b). --- vmmlib/vector.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/vmmlib/vector.hpp b/vmmlib/vector.hpp index 4adc2dec..0a32c720 100644 --- a/vmmlib/vector.hpp +++ b/vmmlib/vector.hpp @@ -468,6 +468,12 @@ inline Vector< M, T > cross( const Vector< 3, T >& a, const Vector< 3, T >& b ) } +template< typename T > +inline Vector< 3, T > cross(const Vector< 3, T >& a, const Vector< 3, T >& b) { + return a.cross(b); +} + + template< size_t M, typename T > inline Vector< M, T > normalize( const Vector< M, T >& vector_ ) { @@ -1135,7 +1141,7 @@ inline T Vector< M, T >::normalize() if ( len == 0 ) return 0; - const T tmp = 1.0 / len; + const T tmp = static_cast(1.0) / len; (*this) *= tmp; return len; } From 60da63d660e30e9670d6e34b693b5ed7ddbd8d66 Mon Sep 17 00:00:00 2001 From: Simon Ruesch Date: Tue, 1 Dec 2015 23:41:57 +0100 Subject: [PATCH 2/2] -default template argument instead of new function --- vmmlib/vector.hpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/vmmlib/vector.hpp b/vmmlib/vector.hpp index 0a32c720..2266bbff 100644 --- a/vmmlib/vector.hpp +++ b/vmmlib/vector.hpp @@ -461,19 +461,12 @@ inline T dot( const Vector< M, T >& first, const Vector< M, T >& second ) } -template< size_t M, typename T > +template< size_t M = 3, typename T > inline Vector< M, T > cross( const Vector< 3, T >& a, const Vector< 3, T >& b ) { return a.cross( b ); } - -template< typename T > -inline Vector< 3, T > cross(const Vector< 3, T >& a, const Vector< 3, T >& b) { - return a.cross(b); -} - - template< size_t M, typename T > inline Vector< M, T > normalize( const Vector< M, T >& vector_ ) {