game/sdlpp/sdlpp_geometry_vector.hpp

30 lines
793 B
C++
Raw Normal View History

#ifndef SDLPP_HPP_GEOMETRY_VECTOR
#define SDLPP_HPP_GEOMETRY_VECTOR
#include "sdlpp_common.hpp"
#include "sdlpp_vector.hpp"
#include <cmath>
namespace SDLPP {
template < typename T >
double vecDotProduct( const Vec2D< T > &a, const Vec2D< T > &b ) {
return a * b;
}
template < typename T > double vecLengthSquared( const Vec2D< T > &vec ) {
return vecDotProduct( vec, vec );
}
template < typename T > double vecLength( const Vec2D< T > &vec ) {
return std::sqrt( vecLengthSquared( vec ) );
}
template < typename T >
double vecDistanceSquared( const Vec2D< T > &a, const Vec2D< T > &b ) {
return vecLengthSquared( a - b );
}
template < typename T >
double vecDistance( const Vec2D< T > &a, const Vec2D< T > &b ) {
return vecLength( a - b );
}
} // namespace SDLPP
#endif