Vector::PiecewiseMultiplicationAdd
and a few other minor changes in the math lib
This commit is contained in:
parent
163481ce4f
commit
ee5392c60d
|
@ -35,7 +35,7 @@ namespace std
|
||||||
// x2
|
// x2
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
::LinearAlgebra::Matrix2x2<ScalarType> operator * ( const ::LinearAlgebra::Matrix2x2<ScalarType> &left, const ::LinearAlgebra::Matrix2x2<ScalarType> &right )
|
inline ::LinearAlgebra::Matrix2x2<ScalarType> operator * ( const ::LinearAlgebra::Matrix2x2<ScalarType> &left, const ::LinearAlgebra::Matrix2x2<ScalarType> &right )
|
||||||
{
|
{
|
||||||
return ::LinearAlgebra::Matrix2x2<ScalarType>( (left.m11 * right.m11) + (left.m12 * right.m21),
|
return ::LinearAlgebra::Matrix2x2<ScalarType>( (left.m11 * right.m11) + (left.m12 * right.m21),
|
||||||
(left.m11 * right.m12) + (left.m12 * right.m22),
|
(left.m11 * right.m12) + (left.m12 * right.m22),
|
||||||
|
@ -44,14 +44,14 @@ template<typename ScalarType>
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
::LinearAlgebra::Vector2<ScalarType> operator * ( const ::LinearAlgebra::Matrix2x2<ScalarType> &matrix, const ::LinearAlgebra::Vector2<ScalarType> &vector )
|
inline ::LinearAlgebra::Vector2<ScalarType> operator * ( const ::LinearAlgebra::Matrix2x2<ScalarType> &matrix, const ::LinearAlgebra::Vector2<ScalarType> &vector )
|
||||||
{
|
{
|
||||||
return ::LinearAlgebra::Vector2<ScalarType>( (matrix.m11 * vector.x) + (matrix.m12 * vector.y),
|
return ::LinearAlgebra::Vector2<ScalarType>( (matrix.m11 * vector.x) + (matrix.m12 * vector.y),
|
||||||
(matrix.m21 * vector.x) + (matrix.m22 * vector.y) );
|
(matrix.m21 * vector.x) + (matrix.m22 * vector.y) );
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
::LinearAlgebra::Vector2<ScalarType> operator * ( const ::LinearAlgebra::Vector2<ScalarType> &vector, const ::LinearAlgebra::Matrix2x2<ScalarType> &left )
|
inline ::LinearAlgebra::Vector2<ScalarType> operator * ( const ::LinearAlgebra::Vector2<ScalarType> &vector, const ::LinearAlgebra::Matrix2x2<ScalarType> &left )
|
||||||
{
|
{
|
||||||
return ::LinearAlgebra::Vector2<ScalarType>( (vector.x * matrix.m11) + (vector.y * matrix.m21),
|
return ::LinearAlgebra::Vector2<ScalarType>( (vector.x * matrix.m11) + (vector.y * matrix.m21),
|
||||||
(vector.x * matrix.m12) + (vector.y * matrix.m22) );
|
(vector.x * matrix.m12) + (vector.y * matrix.m22) );
|
||||||
|
@ -60,7 +60,7 @@ template<typename ScalarType>
|
||||||
// x3
|
// x3
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
::LinearAlgebra::Matrix3x3<ScalarType> operator * ( const ::LinearAlgebra::Matrix3x3<ScalarType> &left, const ::LinearAlgebra::Matrix3x3<ScalarType> &right )
|
inline ::LinearAlgebra::Matrix3x3<ScalarType> operator * ( const ::LinearAlgebra::Matrix3x3<ScalarType> &left, const ::LinearAlgebra::Matrix3x3<ScalarType> &right )
|
||||||
{
|
{
|
||||||
return ::LinearAlgebra::Matrix3x3<ScalarType>( (left.m11 * right.m11) + (left.m12 * right.m21) + (left.m13 * right.m31), (left.m11 * right.m12) + (left.m12 * right.m22) + (left.m13 * right.m32), (left.m11 * right.m13) + (left.m12 * right.m23) + (left.m13 * right.m33),
|
return ::LinearAlgebra::Matrix3x3<ScalarType>( (left.m11 * right.m11) + (left.m12 * right.m21) + (left.m13 * right.m31), (left.m11 * right.m12) + (left.m12 * right.m22) + (left.m13 * right.m32), (left.m11 * right.m13) + (left.m12 * right.m23) + (left.m13 * right.m33),
|
||||||
(left.m21 * right.m11) + (left.m22 * right.m21) + (left.m23 * right.m31), (left.m21 * right.m12) + (left.m22 * right.m22) + (left.m23 * right.m32), (left.m21 * right.m13) + (left.m22 * right.m23) + (left.m23 * right.m33),
|
(left.m21 * right.m11) + (left.m22 * right.m21) + (left.m23 * right.m31), (left.m21 * right.m12) + (left.m22 * right.m22) + (left.m23 * right.m32), (left.m21 * right.m13) + (left.m22 * right.m23) + (left.m23 * right.m33),
|
||||||
|
@ -68,7 +68,7 @@ template<typename ScalarType>
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
::LinearAlgebra::Vector3<ScalarType> operator * ( const ::LinearAlgebra::Matrix3x3<ScalarType> &matrix, const ::LinearAlgebra::Vector3<ScalarType> &vector )
|
inline ::LinearAlgebra::Vector3<ScalarType> operator * ( const ::LinearAlgebra::Matrix3x3<ScalarType> &matrix, const ::LinearAlgebra::Vector3<ScalarType> &vector )
|
||||||
{
|
{
|
||||||
return ::LinearAlgebra::Vector3<ScalarType>( (matrix.m11 * vector.x) + (matrix.m12 * vector.y) + (matrix.m13 * vector.z),
|
return ::LinearAlgebra::Vector3<ScalarType>( (matrix.m11 * vector.x) + (matrix.m12 * vector.y) + (matrix.m13 * vector.z),
|
||||||
(matrix.m21 * vector.x) + (matrix.m22 * vector.y) + (matrix.m23 * vector.z),
|
(matrix.m21 * vector.x) + (matrix.m22 * vector.y) + (matrix.m23 * vector.z),
|
||||||
|
@ -76,7 +76,7 @@ template<typename ScalarType>
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
::LinearAlgebra::Vector3<ScalarType> operator * ( const ::LinearAlgebra::Vector3<ScalarType> &vector, const ::LinearAlgebra::Matrix3x3<ScalarType> &left )
|
inline ::LinearAlgebra::Vector3<ScalarType> operator * ( const ::LinearAlgebra::Vector3<ScalarType> &vector, const ::LinearAlgebra::Matrix3x3<ScalarType> &left )
|
||||||
{
|
{
|
||||||
return ::LinearAlgebra::Vector3<ScalarType>( (vector.x * matrix.m11) + (vector.y * matrix.m21) + (vector.z * matrix.m31),
|
return ::LinearAlgebra::Vector3<ScalarType>( (vector.x * matrix.m11) + (vector.y * matrix.m21) + (vector.z * matrix.m31),
|
||||||
(vector.x * matrix.m12) + (vector.y * matrix.m22) + (vector.z * matrix.m32),
|
(vector.x * matrix.m12) + (vector.y * matrix.m22) + (vector.z * matrix.m32),
|
||||||
|
@ -86,7 +86,7 @@ template<typename ScalarType>
|
||||||
// x4
|
// x4
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
::LinearAlgebra::Matrix4x4<ScalarType> operator * ( const ::LinearAlgebra::Matrix4x4<ScalarType> &left, const ::LinearAlgebra::Matrix4x4<ScalarType> &right )
|
inline ::LinearAlgebra::Matrix4x4<ScalarType> operator * ( const ::LinearAlgebra::Matrix4x4<ScalarType> &left, const ::LinearAlgebra::Matrix4x4<ScalarType> &right )
|
||||||
{
|
{
|
||||||
return ::LinearAlgebra::Matrix4x4<ScalarType>( (left.m11 * right.m11) + (left.m12 * right.m21) + (left.m13 * right.m31) + (left.m14 * right.m41), (left.m11 * right.m12) + (left.m12 * right.m22) + (left.m13 * right.m32) + (left.m14 * right.m42), (left.m11 * right.m13) + (left.m12 * right.m23) + (left.m13 * right.m33) + (left.m14 * right.m43), (left.m11 * right.m14) + (left.m12 * right.m24) + (left.m13 * right.m34) + (left.m14 * right.m44),
|
return ::LinearAlgebra::Matrix4x4<ScalarType>( (left.m11 * right.m11) + (left.m12 * right.m21) + (left.m13 * right.m31) + (left.m14 * right.m41), (left.m11 * right.m12) + (left.m12 * right.m22) + (left.m13 * right.m32) + (left.m14 * right.m42), (left.m11 * right.m13) + (left.m12 * right.m23) + (left.m13 * right.m33) + (left.m14 * right.m43), (left.m11 * right.m14) + (left.m12 * right.m24) + (left.m13 * right.m34) + (left.m14 * right.m44),
|
||||||
(left.m21 * right.m11) + (left.m22 * right.m21) + (left.m23 * right.m31) + (left.m24 * right.m41), (left.m21 * right.m12) + (left.m22 * right.m22) + (left.m23 * right.m32) + (left.m24 * right.m42), (left.m21 * right.m13) + (left.m22 * right.m23) + (left.m23 * right.m33) + (left.m24 * right.m43), (left.m21 * right.m14) + (left.m22 * right.m24) + (left.m23 * right.m34) + (left.m24 * right.m44),
|
(left.m21 * right.m11) + (left.m22 * right.m21) + (left.m23 * right.m31) + (left.m24 * right.m41), (left.m21 * right.m12) + (left.m22 * right.m22) + (left.m23 * right.m32) + (left.m24 * right.m42), (left.m21 * right.m13) + (left.m22 * right.m23) + (left.m23 * right.m33) + (left.m24 * right.m43), (left.m21 * right.m14) + (left.m22 * right.m24) + (left.m23 * right.m34) + (left.m24 * right.m44),
|
||||||
|
@ -95,7 +95,7 @@ template<typename ScalarType>
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
::LinearAlgebra::Vector4<ScalarType> operator * ( const ::LinearAlgebra::Matrix4x4<ScalarType> &matrix, const ::LinearAlgebra::Vector4<ScalarType> &vector )
|
inline ::LinearAlgebra::Vector4<ScalarType> operator * ( const ::LinearAlgebra::Matrix4x4<ScalarType> &matrix, const ::LinearAlgebra::Vector4<ScalarType> &vector )
|
||||||
{
|
{
|
||||||
return ::LinearAlgebra::Vector4<ScalarType>( (matrix.m11 * vector.x) + (matrix.m12 * vector.y) + (matrix.m13 * vector.z) + (matrix.m14 * vector.w),
|
return ::LinearAlgebra::Vector4<ScalarType>( (matrix.m11 * vector.x) + (matrix.m12 * vector.y) + (matrix.m13 * vector.z) + (matrix.m14 * vector.w),
|
||||||
(matrix.m21 * vector.x) + (matrix.m22 * vector.y) + (matrix.m23 * vector.z) + (matrix.m24 * vector.w),
|
(matrix.m21 * vector.x) + (matrix.m22 * vector.y) + (matrix.m23 * vector.z) + (matrix.m24 * vector.w),
|
||||||
|
@ -104,7 +104,7 @@ template<typename ScalarType>
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
::LinearAlgebra::Vector4<ScalarType> operator * ( const ::LinearAlgebra::Vector4<ScalarType> &vector, const ::LinearAlgebra::Matrix4x4<ScalarType> &matrix )
|
inline ::LinearAlgebra::Vector4<ScalarType> operator * ( const ::LinearAlgebra::Vector4<ScalarType> &vector, const ::LinearAlgebra::Matrix4x4<ScalarType> &matrix )
|
||||||
{
|
{
|
||||||
return ::LinearAlgebra::Vector4<ScalarType>( (vector.x * matrix.m11) + (vector.y * matrix.m21) + (vector.z * matrix.m31) + (vector.w * matrix.m41),
|
return ::LinearAlgebra::Vector4<ScalarType>( (vector.x * matrix.m11) + (vector.y * matrix.m21) + (vector.z * matrix.m31) + (vector.w * matrix.m41),
|
||||||
(vector.x * matrix.m12) + (vector.y * matrix.m22) + (vector.z * matrix.m32) + (vector.w * matrix.m42),
|
(vector.x * matrix.m12) + (vector.y * matrix.m22) + (vector.z * matrix.m32) + (vector.w * matrix.m42),
|
||||||
|
|
|
@ -163,12 +163,18 @@ namespace LinearAlgebra
|
||||||
Vector4<ScalarType> GetRowVector( unsigned int rowID ) const;
|
Vector4<ScalarType> GetRowVector( unsigned int rowID ) const;
|
||||||
const Vector4<ScalarType> & GetColumnVector( unsigned int colID ) const;
|
const Vector4<ScalarType> & GetColumnVector( unsigned int colID ) const;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType> LinearAlgebra::Matrix2x2<ScalarType> operator * ( const ScalarType &left, const LinearAlgebra::Matrix2x2<ScalarType> &right );
|
||||||
|
template<typename ScalarType> LinearAlgebra::Matrix3x3<ScalarType> operator * ( const ScalarType &left, const LinearAlgebra::Matrix3x3<ScalarType> &right );
|
||||||
|
template<typename ScalarType> LinearAlgebra::Matrix4x4<ScalarType> operator * ( const ScalarType &left, const LinearAlgebra::Matrix4x4<ScalarType> &right );
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Body
|
// Body
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace LinearAlgebra
|
||||||
|
{
|
||||||
// Matrix2x2<ScalarType> ///////////////////////////////////////
|
// Matrix2x2<ScalarType> ///////////////////////////////////////
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
|
@ -753,4 +759,22 @@ namespace LinearAlgebra
|
||||||
{ return this->v[colID]; }
|
{ return this->v[colID]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline LinearAlgebra::Matrix2x2<ScalarType> operator * ( const ScalarType &left, const LinearAlgebra::Matrix2x2<ScalarType> &right )
|
||||||
|
{
|
||||||
|
return right * left;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline LinearAlgebra::Matrix3x3<ScalarType> operator * ( const ScalarType &left, const LinearAlgebra::Matrix3x3<ScalarType> &right )
|
||||||
|
{
|
||||||
|
return right * left;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline LinearAlgebra::Matrix4x4<ScalarType> operator * ( const ScalarType &left, const LinearAlgebra::Matrix4x4<ScalarType> &right )
|
||||||
|
{
|
||||||
|
return right * left;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -61,55 +61,29 @@ namespace Oyster { namespace Math //! Oyster's native math library
|
||||||
|
|
||||||
inline ::Oyster::Math::Float2 & operator *= ( ::Oyster::Math::Float2 &left, const ::Oyster::Math::Float2 &right )
|
inline ::Oyster::Math::Float2 & operator *= ( ::Oyster::Math::Float2 &left, const ::Oyster::Math::Float2 &right )
|
||||||
{
|
{
|
||||||
left.x *= right.x;
|
return left.PiecewiseMultiplicationAdd( right );
|
||||||
left.y *= right.y;
|
|
||||||
return left;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ::Oyster::Math::Float2 operator * ( const ::Oyster::Math::Float2 &left, const ::Oyster::Math::Float2 &right )
|
inline ::Oyster::Math::Float2 operator * ( const ::Oyster::Math::Float2 &left, const ::Oyster::Math::Float2 &right )
|
||||||
{ return left.PiecewiseMultiplication( right; }
|
{
|
||||||
|
return left.PiecewiseMultiplication( right );
|
||||||
inline ::Oyster::Math::Float2 operator * ( const ::Oyster::Math::Float &left, const ::Oyster::Math::Float2 &right )
|
}
|
||||||
{ return ::Oyster::Math::Float2(right) *= left; }
|
|
||||||
|
|
||||||
inline ::Oyster::Math::Float3 & operator *= ( ::Oyster::Math::Float3 &left, const ::Oyster::Math::Float3 &right )
|
inline ::Oyster::Math::Float3 & operator *= ( ::Oyster::Math::Float3 &left, const ::Oyster::Math::Float3 &right )
|
||||||
{
|
{
|
||||||
left.x *= right.x;
|
return left.PiecewiseMultiplicationAdd( right );
|
||||||
left.y *= right.y;
|
|
||||||
left.z *= right.z;
|
|
||||||
return left;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ::Oyster::Math::Float3 operator * ( const ::Oyster::Math::Float3 &left, const ::Oyster::Math::Float3 &right )
|
inline ::Oyster::Math::Float3 operator * ( const ::Oyster::Math::Float3 &left, const ::Oyster::Math::Float3 &right )
|
||||||
{ return left.PiecewiseMultiplication( right ); }
|
{
|
||||||
|
return left.PiecewiseMultiplication( right );
|
||||||
inline ::Oyster::Math::Float3 operator * ( const ::Oyster::Math::Float &left, const ::Oyster::Math::Float3 &right )
|
}
|
||||||
{ return ::Oyster::Math::Float3(right) *= left; }
|
|
||||||
|
|
||||||
inline ::Oyster::Math::Float4 & operator *= ( ::Oyster::Math::Float4 &left, const ::Oyster::Math::Float4 &right )
|
inline ::Oyster::Math::Float4 & operator *= ( ::Oyster::Math::Float4 &left, const ::Oyster::Math::Float4 &right )
|
||||||
{
|
{
|
||||||
left.x *= right.x;
|
return left.PiecewiseMultiplicationAdd( right );
|
||||||
left.y *= right.y;
|
|
||||||
left.z *= right.z;
|
|
||||||
left.w *= right.w;
|
|
||||||
return left;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline ::Oyster::Math::Float4 operator * ( const ::Oyster::Math::Float4 &left, const ::Oyster::Math::Float4 &right )
|
|
||||||
{ return left.PiecewiseMultiplication( right ); }
|
|
||||||
|
|
||||||
inline ::Oyster::Math::Float4 operator * ( const ::Oyster::Math::Float &left, const ::Oyster::Math::Float4 &right )
|
|
||||||
{ return ::Oyster::Math::Float4(right) *= left; }
|
|
||||||
|
|
||||||
inline ::Oyster::Math::Float2x2 operator * ( const ::Oyster::Math::Float &left, const ::Oyster::Math::Float2x2 &right )
|
|
||||||
{ return ::Oyster::Math::Float2x2(right) *= left; }
|
|
||||||
|
|
||||||
inline ::Oyster::Math::Float3x3 operator * ( const ::Oyster::Math::Float &left, const ::Oyster::Math::Float3x3 &right )
|
|
||||||
{ return ::Oyster::Math::Float3x3(right) *= left; }
|
|
||||||
|
|
||||||
inline ::Oyster::Math::Float4x4 operator * ( const ::Oyster::Math::Float &left, const ::Oyster::Math::Float4x4 &right )
|
|
||||||
{ return ::Oyster::Math::Float4x4(right) *= left; }
|
|
||||||
|
|
||||||
namespace Oyster { namespace Math2D //! Oyster's native math library specialized for 2D
|
namespace Oyster { namespace Math2D //! Oyster's native math library specialized for 2D
|
||||||
{
|
{
|
||||||
using namespace ::Oyster::Math; // deliberate inheritance from ::Oyster::Math namespace
|
using namespace ::Oyster::Math; // deliberate inheritance from ::Oyster::Math namespace
|
||||||
|
|
|
@ -60,6 +60,9 @@ namespace LinearAlgebra
|
||||||
//! @return (a.x * b.x, a.y * b.y)
|
//! @return (a.x * b.x, a.y * b.y)
|
||||||
Vector2<ScalarType> PiecewiseMultiplication( const Vector2<ScalarType> &vector ) const;
|
Vector2<ScalarType> PiecewiseMultiplication( const Vector2<ScalarType> &vector ) const;
|
||||||
|
|
||||||
|
//! @return a = (a.x * b.x, a.y * b.y)
|
||||||
|
Vector2<ScalarType> & PiecewiseMultiplicationAdd( const Vector2<ScalarType> &vector );
|
||||||
|
|
||||||
Vector2<ScalarType> & Normalize( );
|
Vector2<ScalarType> & Normalize( );
|
||||||
Vector2<ScalarType> GetNormalized( ) const;
|
Vector2<ScalarType> GetNormalized( ) const;
|
||||||
};
|
};
|
||||||
|
@ -118,6 +121,9 @@ namespace LinearAlgebra
|
||||||
//! @return (a.x * b.x, a.y * b.y, a.z * b.z)
|
//! @return (a.x * b.x, a.y * b.y, a.z * b.z)
|
||||||
Vector3<ScalarType> PiecewiseMultiplication( const Vector3<ScalarType> &vector ) const;
|
Vector3<ScalarType> PiecewiseMultiplication( const Vector3<ScalarType> &vector ) const;
|
||||||
|
|
||||||
|
//! @return a = (a.x * b.x, a.y * b.y, a.z * b.z)
|
||||||
|
Vector3<ScalarType> & PiecewiseMultiplicationAdd( const Vector3<ScalarType> &vector );
|
||||||
|
|
||||||
Vector3<ScalarType> & Normalize( );
|
Vector3<ScalarType> & Normalize( );
|
||||||
Vector3<ScalarType> GetNormalized( ) const;
|
Vector3<ScalarType> GetNormalized( ) const;
|
||||||
};
|
};
|
||||||
|
@ -175,17 +181,27 @@ namespace LinearAlgebra
|
||||||
ScalarType GetMagnitude( ) const;
|
ScalarType GetMagnitude( ) const;
|
||||||
ScalarType Dot( const Vector4<ScalarType> &vector ) const;
|
ScalarType Dot( const Vector4<ScalarType> &vector ) const;
|
||||||
|
|
||||||
//! @return (a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w )
|
//! @return (a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w)
|
||||||
Vector4<ScalarType> PiecewiseMultiplication( const Vector4<ScalarType> &vector ) const;
|
Vector4<ScalarType> PiecewiseMultiplication( const Vector4<ScalarType> &vector ) const;
|
||||||
|
|
||||||
|
//! @return a = (a.x * b.x, a.y * b.y, a.z * b.z, a.w * b.w)
|
||||||
|
Vector4<ScalarType> & PiecewiseMultiplicationAdd( const Vector4<ScalarType> &vector );
|
||||||
|
|
||||||
Vector4<ScalarType> & Normalize( );
|
Vector4<ScalarType> & Normalize( );
|
||||||
Vector4<ScalarType> GetNormalized( ) const;
|
Vector4<ScalarType> GetNormalized( ) const;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType> ::LinearAlgebra::Vector2<ScalarType> operator * ( const ScalarType &left, const ::LinearAlgebra::Vector2<ScalarType> &right );
|
||||||
|
template<typename ScalarType> ::LinearAlgebra::Vector3<ScalarType> operator * ( const ScalarType &left, const ::LinearAlgebra::Vector3<ScalarType> &right );
|
||||||
|
template<typename ScalarType> ::LinearAlgebra::Vector4<ScalarType> operator * ( const ScalarType &left, const ::LinearAlgebra::Vector4<ScalarType> &right );
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
// Body
|
// Body
|
||||||
///////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace LinearAlgebra
|
||||||
|
{
|
||||||
// Vector2<ScalarType> ///////////////////////////////////////
|
// Vector2<ScalarType> ///////////////////////////////////////
|
||||||
|
|
||||||
template<typename ScalarType> const Vector2<ScalarType> Vector2<ScalarType>::null = Vector2<ScalarType>( 0, 0 );
|
template<typename ScalarType> const Vector2<ScalarType> Vector2<ScalarType>::null = Vector2<ScalarType>( 0, 0 );
|
||||||
|
@ -342,6 +358,14 @@ namespace LinearAlgebra
|
||||||
return Vector2<ScalarType>( this->x * vector.x, this->y * vector.y );
|
return Vector2<ScalarType>( this->x * vector.x, this->y * vector.y );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline Vector2<ScalarType> & Vector2<ScalarType>::PiecewiseMultiplicationAdd( const Vector2<ScalarType> &vector )
|
||||||
|
{
|
||||||
|
this->x *= vector.x;
|
||||||
|
this->y *= vector.y;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
inline Vector2<ScalarType> & Vector2<ScalarType>::Normalize( )
|
inline Vector2<ScalarType> & Vector2<ScalarType>::Normalize( )
|
||||||
{ return (*this) /= this->GetLength(); }
|
{ return (*this) /= this->GetLength(); }
|
||||||
|
@ -520,6 +544,15 @@ namespace LinearAlgebra
|
||||||
return Vector3<ScalarType>( this->x * vector.x, this->y * vector.y, this->z * vector.z );
|
return Vector3<ScalarType>( this->x * vector.x, this->y * vector.y, this->z * vector.z );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline Vector3<ScalarType> & Vector3<ScalarType>::PiecewiseMultiplicationAdd( const Vector3<ScalarType> &vector )
|
||||||
|
{
|
||||||
|
this->x *= vector.x;
|
||||||
|
this->y *= vector.y;
|
||||||
|
this->z *= vector.z;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
inline Vector3<ScalarType> & Vector3<ScalarType>::Normalize( )
|
inline Vector3<ScalarType> & Vector3<ScalarType>::Normalize( )
|
||||||
{ return (*this) /= this->GetLength(); }
|
{ return (*this) /= this->GetLength(); }
|
||||||
|
@ -704,6 +737,16 @@ namespace LinearAlgebra
|
||||||
return Vector4<ScalarType>( this->x * vector.x, this->y * vector.y, this->z * vector.z, this->w * vector.w );
|
return Vector4<ScalarType>( this->x * vector.x, this->y * vector.y, this->z * vector.z, this->w * vector.w );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline Vector4<ScalarType> & Vector4<ScalarType>::PiecewiseMultiplicationAdd( const Vector4<ScalarType> &vector )
|
||||||
|
{
|
||||||
|
this->x *= vector.x;
|
||||||
|
this->y *= vector.y;
|
||||||
|
this->z *= vector.z;
|
||||||
|
this->w *= vector.w;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename ScalarType>
|
template<typename ScalarType>
|
||||||
inline Vector4<ScalarType> & Vector4<ScalarType>::Normalize( )
|
inline Vector4<ScalarType> & Vector4<ScalarType>::Normalize( )
|
||||||
{ return (*this) /= this->GetLength(); }
|
{ return (*this) /= this->GetLength(); }
|
||||||
|
@ -713,4 +756,22 @@ namespace LinearAlgebra
|
||||||
{ return Vector4<ScalarType>(*this).Normalize(); }
|
{ return Vector4<ScalarType>(*this).Normalize(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Vector2<ScalarType> operator * ( const ScalarType &left, const ::LinearAlgebra::Vector2<ScalarType> &right )
|
||||||
|
{
|
||||||
|
return right * left;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Vector3<ScalarType> operator * ( const ScalarType &left, const ::LinearAlgebra::Vector3<ScalarType> &right )
|
||||||
|
{
|
||||||
|
return right * left;
|
||||||
|
}
|
||||||
|
|
||||||
|
template<typename ScalarType>
|
||||||
|
inline ::LinearAlgebra::Vector4<ScalarType> operator * ( const ScalarType &left, const ::LinearAlgebra::Vector4<ScalarType> &right )
|
||||||
|
{
|
||||||
|
return right * left;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue