Optimization
This commit is contained in:
parent
0a877b5b9e
commit
2cd51e29ac
@ -189,7 +189,7 @@ namespace Phanes::Core::Math::Detail
|
||||
static constexpr bool map(const Phanes::Core::Math::TVector2<T, S>& v1, const Phanes::Core::Math::TVector2<T, S>& v2)
|
||||
{
|
||||
return (Phanes::Core::Math::Abs(v1.x - v2.x) > P_FLT_INAC ||
|
||||
Phanes::Core::Math::Abs(v1.y - v2.y) > P_FLT_INAC);
|
||||
Phanes::Core::Math::Abs(v1.y - v2.y) > P_FLT_INAC);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -127,7 +127,7 @@ namespace Phanes::Core::Math {
|
||||
*/
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator+= (TVector2<T, S>& v1, T s);
|
||||
TVector2<T, S>& operator+= (TVector2<T, S>& v1, T s);
|
||||
|
||||
/**
|
||||
* Addition operation on same TVector2<T, S> (this) by a another TVector2<T, S>.
|
||||
@ -137,7 +137,7 @@ namespace Phanes::Core::Math {
|
||||
*/
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator+= (TVector2<T, S>& v1, const TVector2<T, S>& v2);
|
||||
TVector2<T, S>& operator+= (TVector2<T, S>& v1, const TVector2<T, S>& v2);
|
||||
|
||||
/**
|
||||
* Substraction operation on same TVector2<T, S> (this) by a floating point.
|
||||
@ -147,7 +147,7 @@ namespace Phanes::Core::Math {
|
||||
*/
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator-= (TVector2<T, S>& v1, T s);
|
||||
TVector2<T, S>& operator-= (TVector2<T, S>& v1, T s);
|
||||
|
||||
/**
|
||||
* Substraction operation on same TVector2<T, S> (this) by a another TVector2<T, S>.
|
||||
@ -157,7 +157,7 @@ namespace Phanes::Core::Math {
|
||||
*/
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator-= (TVector2<T, S>& v1, const TVector2<T, S>& v2);
|
||||
TVector2<T, S>& operator-= (TVector2<T, S>& v1, const TVector2<T, S>& v2);
|
||||
|
||||
/**
|
||||
* Multiplication of TVector2<T, S> (this) with a floating point.
|
||||
@ -167,7 +167,7 @@ namespace Phanes::Core::Math {
|
||||
*/
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator*= (TVector2<T, S>& v1, T s);
|
||||
TVector2<T, S>& operator*= (TVector2<T, S>& v1, T s);
|
||||
|
||||
/// <summary>
|
||||
/// Componentwise multiplication of vector by other vector.
|
||||
@ -178,7 +178,7 @@ namespace Phanes::Core::Math {
|
||||
/// <param name="v2"></param>
|
||||
/// <returns>Copy of v1.</returns>
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator*= (TVector2<T, S>& v1, const TVector2<T, S>& v2);
|
||||
TVector2<T, S>& operator*= (TVector2<T, S>& v1, const TVector2<T, S>& v2);
|
||||
|
||||
/**
|
||||
* Devision of Vector (this) by floating point.
|
||||
@ -188,7 +188,7 @@ namespace Phanes::Core::Math {
|
||||
*/
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator/= (TVector2<T, S>& v1, T s);
|
||||
TVector2<T, S>& operator/= (TVector2<T, S>& v1, T s);
|
||||
|
||||
/// <summary>
|
||||
/// Componentwise division of vector by other vector.
|
||||
@ -199,7 +199,7 @@ namespace Phanes::Core::Math {
|
||||
/// <param name="v2"></param>
|
||||
/// <returns>Copy of v1.</returns>
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator/= (TVector2<T, S>& v1, const TVector2<T, S>& v2);
|
||||
TVector2<T, S>& operator/= (TVector2<T, S>& v1, const TVector2<T, S>& v2);
|
||||
|
||||
/**
|
||||
* Scale of Vector by floating point. (> Creates a new TVector2<T, S>)
|
||||
@ -236,6 +236,10 @@ namespace Phanes::Core::Math {
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator/ (const TVector2<T, S>& v1, T s);
|
||||
|
||||
|
||||
template<RealType T, bool S>
|
||||
inline TVector2<T, S> operator/ (T s, const TVector2<T, S>& v1);
|
||||
|
||||
/// <summary>
|
||||
/// Componentwise multiplication with vector by vector.
|
||||
/// </summary>
|
||||
@ -262,24 +266,6 @@ namespace Phanes::Core::Math {
|
||||
return v1 * s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Division of Vector by floating point. (> For convenience not arithmethicaly correct. Works like overloaded counterpart.)
|
||||
*
|
||||
* @param(v1) Vector to multiply with
|
||||
* @param(s Floating point to divide with
|
||||
*
|
||||
* @return Result Vector
|
||||
*/
|
||||
|
||||
|
||||
template<RealType T, bool S>
|
||||
inline TVector2<T, S> operator/ (T s, const TVector2<T, S>& v1);
|
||||
|
||||
|
||||
|
||||
template<RealType T, bool S>
|
||||
inline TVector2<T, S> operator- (T s, const TVector2<T, S>& v1);
|
||||
|
||||
/**
|
||||
* Componentwise addition of Vector with floating point.
|
||||
*
|
||||
@ -316,6 +302,10 @@ namespace Phanes::Core::Math {
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator- (const TVector2<T, S>& v1, T s);
|
||||
|
||||
|
||||
template<RealType T, bool S>
|
||||
inline TVector2<T, S> operator- (T s, const TVector2<T, S>& v1);
|
||||
|
||||
/**
|
||||
* Componentwise substraction of Vector with Vector.
|
||||
*
|
||||
@ -356,6 +346,7 @@ namespace Phanes::Core::Math {
|
||||
bool operator!= (const TVector2<T, S>& v1, const TVector2<T, S>& v2);
|
||||
|
||||
|
||||
|
||||
template<RealType T, bool A>
|
||||
TVector2<T, A>& operator++(TVector2<T, A>& v1);
|
||||
|
||||
@ -812,7 +803,7 @@ namespace Phanes::Core::Math {
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> Negate(const TVector2<T, S>& v1)
|
||||
{
|
||||
return ((T)1.0 - v1);
|
||||
return ((T)0.0 - v1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -43,56 +43,56 @@ namespace Phanes::Core::Math
|
||||
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator+=(TVector2<T, S>& v1, const TVector2<T, S>& v2)
|
||||
TVector2<T, S>& operator+=(TVector2<T, S>& v1, const TVector2<T, S>& v2)
|
||||
{
|
||||
Detail::compute_vec2_add<T, S>::map(v1, v1, v2);
|
||||
return v1;
|
||||
}
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator+=(TVector2<T, S>& v1, T s)
|
||||
TVector2<T, S>& operator+=(TVector2<T, S>& v1, T s)
|
||||
{
|
||||
Detail::compute_vec2_add<T, S>::map(v1, v1, s);
|
||||
return v1;
|
||||
}
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator-=(TVector2<T, S>& v1, const TVector2<T, S>& v2)
|
||||
TVector2<T, S>& operator-=(TVector2<T, S>& v1, const TVector2<T, S>& v2)
|
||||
{
|
||||
Detail::compute_vec2_sub<T, S>::map(v1, v1, v2);
|
||||
return v1;
|
||||
}
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator-=(TVector2<T, S>& v1, T s)
|
||||
TVector2<T, S>& operator-=(TVector2<T, S>& v1, T s)
|
||||
{
|
||||
Detail::compute_vec2_sub<T, S>::map(v1, v1, s);
|
||||
return v1;
|
||||
}
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator*=(TVector2<T, S>& v1, const TVector2<T, S>& v2)
|
||||
TVector2<T, S>& operator*=(TVector2<T, S>& v1, const TVector2<T, S>& v2)
|
||||
{
|
||||
Detail::compute_vec2_mul<T, S>::map(v1, v1, v2);
|
||||
return v1;
|
||||
}
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator*=(TVector2<T, S>& v1, T s)
|
||||
TVector2<T, S>& operator*=(TVector2<T, S>& v1, T s)
|
||||
{
|
||||
Detail::compute_vec2_mul<T, S>::map(v1, v1, s);
|
||||
return v1;
|
||||
}
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator/=(TVector2<T, S>& v1, const TVector2<T, S>& v2)
|
||||
TVector2<T, S>& operator/=(TVector2<T, S>& v1, const TVector2<T, S>& v2)
|
||||
{
|
||||
Detail::compute_vec2_div<T, S>::map(v1, v1, v2);
|
||||
return v1;
|
||||
}
|
||||
|
||||
template<RealType T, bool S>
|
||||
TVector2<T, S> operator/=(TVector2<T, S>& v1, T s)
|
||||
TVector2<T, S>& operator/=(TVector2<T, S>& v1, T s)
|
||||
{
|
||||
Detail::compute_vec2_div<T, S>::map(v1, v1, s);
|
||||
return v1;
|
||||
|
Loading…
x
Reference in New Issue
Block a user