Bug fixes

This commit is contained in:
THoehne 2024-08-22 14:25:37 +02:00
parent ca84d34703
commit cf67b283f5
7 changed files with 103 additions and 98 deletions

View File

@ -146,10 +146,8 @@ namespace Phanes::Core::Math::Detail
static constexpr void map(Phanes::Core::Math::TIntVector2<T, false>& r, const Phanes::Core::Math::TIntVector2<T, false>& v1, T s) static constexpr void map(Phanes::Core::Math::TIntVector2<T, false>& r, const Phanes::Core::Math::TIntVector2<T, false>& v1, T s)
{ {
s = (T)1.0 / s; r.x = v1.x / s;
r.y = v1.y / s;
r.x = v1.x * s;
r.y = v1.y * s;
} }
}; };

View File

@ -77,7 +77,7 @@ namespace Phanes::Core::Math::Detail
{ {
v1.x = x; v1.x = x;
v1.y = y; v1.y = y;
v1.y = z; v1.z = z;
v1.w = (T)0; v1.w = (T)0;
} }
@ -169,11 +169,9 @@ namespace Phanes::Core::Math::Detail
static constexpr void map(Phanes::Core::Math::TIntVector3<T, false>& r, const Phanes::Core::Math::TIntVector3<T, false>& v1, T s) static constexpr void map(Phanes::Core::Math::TIntVector3<T, false>& r, const Phanes::Core::Math::TIntVector3<T, false>& v1, T s)
{ {
s = (T)1.0 / s; r.x = v1.x / s;
r.y = v1.y / s;
r.x = v1.x * s; r.z = v1.z / s;
r.y = v1.y * s;
r.z = v1.z * s;
} }
}; };

View File

@ -127,10 +127,10 @@ namespace Phanes::Core::Math {
// ======================== // // ======================== //
/** /**
* Addition operation on same TIntVector2<T, A> (this) by a floating point value. * Addition operation on same TIntVector2<T, A> (this) by a scalar value.
* *
* @param(v1) Vector to add to * @param(v1) Vector to add to
* @param(s) Floating point to add * @param(s) Scalar to add
*/ */
template<IntType T, bool A> template<IntType T, bool A>
@ -147,10 +147,10 @@ namespace Phanes::Core::Math {
TIntVector2<T, A> operator+= (TIntVector2<T, A>& v1, const TIntVector2<T, A>& v2); TIntVector2<T, A> operator+= (TIntVector2<T, A>& v1, const TIntVector2<T, A>& v2);
/** /**
* Substraction operation on same TIntVector2<T, A> (this) by a floating point. * Substraction operation on same TIntVector2<T, A> (this) by a scalar.
* *
* @param(v1) Vector to substract from * @param(v1) Vector to substract from
* @param(v2) Floating point to substract * @param(v2) Scalar to substract
*/ */
template<IntType T, bool A> template<IntType T, bool A>
@ -168,27 +168,33 @@ namespace Phanes::Core::Math {
/** /**
* Multiplication of TIntVector2<T, A> (this) with a floating point. * Multiplication of TIntVector2<T, A> (this) with a scalar.
* *
* @param(v1) Vector to multiply with * @param(v1) Vector to multiply with
* @param(s Floating point to multiply with * @param(s) scalar to multiply with
*/ */
template<IntType T, bool A> template<IntType T, bool A>
TIntVector2<T, A> operator*= (TIntVector2<T, A>& v1, T s); TIntVector2<T, A> operator*= (TIntVector2<T, A>& v1, T s);
template<IntType T, bool A>
TIntVector2<T, A> operator*= (TIntVector2<T, A>& v1, const TIntVector2<T, A>& v2);
/** /**
* Devision of Vector * Devision of Vector
* *
* @param(v1) Vector to divide with * @param(v1) Vector to divide with
* @param(s) Scalar to divide with * @param(s) Scalar to divide with
* *
* @note Result is rounded (obviously) * @note Result is rounded
*/ */
template<IntType T, bool A> template<IntType T, bool A>
TIntVector2<T, A> operator/= (TIntVector2<T, A>& v1, T s); TIntVector2<T, A> operator/= (TIntVector2<T, A>& v1, T s);
template<IntType T, bool A>
TIntVector2<T, A> operator/= (TIntVector2<T, A>& v1, const TIntVector2<T, A>& v2);
/** /**
* Stores the remainder of division by a scalar. * Stores the remainder of division by a scalar.
* *
@ -434,6 +440,11 @@ namespace Phanes::Core::Math {
// TIntVector2 static function implementation // // TIntVector2 static function implementation //
// ============================================== // // ============================================== //
template<IntType T>
T DotP(const TIntVector2<T, false>& v, const TIntVector2<T, false>& v1)
{
return v.x * v1.x + v.y * v1.y;
}
template<IntType T> template<IntType T>
TIntVector2<T, false> MaxV(TIntVector2<T, false>& v1, const TIntVector2<T, false>& v2) TIntVector2<T, false> MaxV(TIntVector2<T, false>& v1, const TIntVector2<T, false>& v2)
@ -462,6 +473,13 @@ namespace Phanes::Core::Math {
return v1; return v1;
} }
/// <summary>
/// Returns signs of numbers (1 / -1). <br>
/// Returns 1 for zero.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="v1"></param>
/// <returns></returns>
template<IntType T> template<IntType T>
TIntVector2<T, false> SignVectorV(TIntVector2<T, false>& v1) TIntVector2<T, false> SignVectorV(TIntVector2<T, false>& v1)
{ {
@ -514,6 +532,8 @@ namespace Phanes::Core::Math {
{ {
v1.x = -v1.x; v1.x = -v1.x;
v1.y = -v1.y; v1.y = -v1.y;
return v1;
} }
/** /**
@ -530,7 +550,7 @@ namespace Phanes::Core::Math {
template<IntType T> template<IntType T>
inline bool IsPerpendicular(const TIntVector2<T, false>& v1, const TIntVector2<T, false>& v2) inline bool IsPerpendicular(const TIntVector2<T, false>& v1, const TIntVector2<T, false>& v2)
{ {
return (abs(DotP(v1, v2)) = 0); return (Abs(DotP(v1, v2)) == 0);
} }
/** /**
@ -547,7 +567,7 @@ namespace Phanes::Core::Math {
template<IntType T> template<IntType T>
inline bool IsParallel(const TIntVector2<T, false>& v1, const TIntVector2<T, false>& v2) inline bool IsParallel(const TIntVector2<T, false>& v1, const TIntVector2<T, false>& v2)
{ {
return (abs(DotP(v1, v2)) = 1); return ((v1.x / v2.x) == (v1.y / v2.y));
} }
/** /**
@ -564,7 +584,8 @@ namespace Phanes::Core::Math {
template<IntType T> template<IntType T>
inline bool IsCoincident(const TIntVector2<T, false>& v1, const TIntVector2<T, false>& v2) inline bool IsCoincident(const TIntVector2<T, false>& v1, const TIntVector2<T, false>& v2)
{ {
return (DotP(v1, v2) = 1); T tmp = v1.x / v2.x;
return (tmp == (v1.y / v2.y) && tmp > -1);
} }
/** /**

View File

@ -267,7 +267,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector2<T, S> operator&(TIntVector2<T, S>& v1, const TIntVector2<T, S>& v2) TIntVector2<T, S> operator&(TIntVector2<T, S>& v1, const TIntVector2<T, S>& v2)
{ {
TVector2<T, S> r; TIntVector2<T, S> r;
Detail::compute_ivec2_and<T, S>::map(r, v1, v2); Detail::compute_ivec2_and<T, S>::map(r, v1, v2);
return r; return r;
} }
@ -275,7 +275,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector2<T, S> operator&(TIntVector2<T, S>& v1, T s) TIntVector2<T, S> operator&(TIntVector2<T, S>& v1, T s)
{ {
TVector2<T, S> r; TIntVector2<T, S> r;
Detail::compute_ivec2_and<T, S>::map(r, v1, s); Detail::compute_ivec2_and<T, S>::map(r, v1, s);
return r; return r;
} }
@ -283,7 +283,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector2<T, S> operator|(TIntVector2<T, S>& v1, const TIntVector2<T, S>& v2) TIntVector2<T, S> operator|(TIntVector2<T, S>& v1, const TIntVector2<T, S>& v2)
{ {
TVector2<T, S> r; TIntVector2<T, S> r;
Detail::compute_ivec2_or<T, S>::map(r, v1, v2); Detail::compute_ivec2_or<T, S>::map(r, v1, v2);
return r; return r;
} }
@ -291,7 +291,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector2<T, S> operator|(TIntVector2<T, S>& v1, T s) TIntVector2<T, S> operator|(TIntVector2<T, S>& v1, T s)
{ {
TVector2<T, S> r; TIntVector2<T, S> r;
Detail::compute_ivec2_or<T, S>::map(r, v1, s); Detail::compute_ivec2_or<T, S>::map(r, v1, s);
return r; return r;
} }
@ -299,7 +299,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector2<T, S> operator^(TIntVector2<T, S>& v1, const TIntVector2<T, S>& v2) TIntVector2<T, S> operator^(TIntVector2<T, S>& v1, const TIntVector2<T, S>& v2)
{ {
TVector2<T, S> r; TIntVector2<T, S> r;
Detail::compute_ivec2_xor<T, S>::map(r, v1, v2); Detail::compute_ivec2_xor<T, S>::map(r, v1, v2);
return r; return r;
} }
@ -307,7 +307,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector2<T, S> operator^(TIntVector2<T, S>& v1, T s) TIntVector2<T, S> operator^(TIntVector2<T, S>& v1, T s)
{ {
TVector2<T, S> r; TIntVector2<T, S> r;
Detail::compute_ivec2_xor<T, S>::map(r, v1, s); Detail::compute_ivec2_xor<T, S>::map(r, v1, s);
return r; return r;
} }
@ -315,7 +315,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector2<T, S> operator<<(TIntVector2<T, S>& v1, const TIntVector2<T, S>& v2) TIntVector2<T, S> operator<<(TIntVector2<T, S>& v1, const TIntVector2<T, S>& v2)
{ {
TVector2<T, S> r; TIntVector2<T, S> r;
Detail::compute_ivec2_left_shift<T, S>::map(r, v1, v2); Detail::compute_ivec2_left_shift<T, S>::map(r, v1, v2);
return r; return r;
} }
@ -323,7 +323,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector2<T, S> operator<<(TIntVector2<T, S>& v1, T s) TIntVector2<T, S> operator<<(TIntVector2<T, S>& v1, T s)
{ {
TVector2<T, S> r; TIntVector2<T, S> r;
Detail::compute_ivec2_left_shift<T, S>::map(r, v1, s); Detail::compute_ivec2_left_shift<T, S>::map(r, v1, s);
return r; return r;
} }
@ -331,7 +331,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector2<T, S> operator>>(TIntVector2<T, S>& v1, const TIntVector2<T, S>& v2) TIntVector2<T, S> operator>>(TIntVector2<T, S>& v1, const TIntVector2<T, S>& v2)
{ {
TVector2<T, S> r; TIntVector2<T, S> r;
Detail::compute_ivec2_right_shift<T, S>::map(r, v1, v2); Detail::compute_ivec2_right_shift<T, S>::map(r, v1, v2);
return r; return r;
} }
@ -339,7 +339,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector2<T, S> operator>>(TIntVector2<T, S>& v1, T s) TIntVector2<T, S> operator>>(TIntVector2<T, S>& v1, T s)
{ {
TVector2<T, S> r; TIntVector2<T, S> r;
Detail::compute_ivec2_right_shift<T, S>::map(r, v1, s); Detail::compute_ivec2_right_shift<T, S>::map(r, v1, s);
return r; return r;
} }
@ -347,7 +347,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector2<T, S> operator~(TIntVector2<T, S>& v1) TIntVector2<T, S> operator~(TIntVector2<T, S>& v1)
{ {
TVector2<T, S> r; TIntVector2<T, S> r;
Detail::compute_ivec2_bnot<T, S>::map(r, v1); Detail::compute_ivec2_bnot<T, S>::map(r, v1);
return r; return r;
} }
@ -376,14 +376,14 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector2<T, S>& operator++(TIntVector2<T, S>& v1) TIntVector2<T, S>& operator++(TIntVector2<T, S>& v1)
{ {
Detail::compute_ivec2_inc<T, S>::map(v1); Detail::compute_ivec2_inc<T, S>::map(v1, v1);
return v1; return v1;
} }
template<IntType T, bool S> template<IntType T, bool S>
TIntVector2<T, S>& operator--(TIntVector2<T, S>& v1) TIntVector2<T, S>& operator--(TIntVector2<T, S>& v1)
{ {
Detail::compute_ivec2_inc<T, S>::map(v1); Detail::compute_ivec2_dec<T, S>::map(v1, v1);
return v1; return v1;
} }

View File

@ -393,11 +393,11 @@ namespace Phanes::Core::Math {
*/ */
template<IntType T> template<IntType T>
TIntVector3<T, false> CrossPV(TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2) TIntVector3<T, false>& CrossPV(TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2)
{ {
float x = v1.x; T x = v1.x;
float y = v1.y; T y = v1.y;
float z = v1.z; T z = v1.z;
v1.x = (y * v2.z) - (z * v2.y); v1.x = (y * v2.z) - (z * v2.y);
v1.y = (z * v2.x) - (x * v2.z); v1.y = (z * v2.x) - (x * v2.z);
@ -416,7 +416,7 @@ namespace Phanes::Core::Math {
*/ */
template<IntType T> template<IntType T>
TIntVector3<T, false> MaxV(TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2) TIntVector3<T, false>& MaxV(TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2)
{ {
v1.x = Phanes::Core::Math::Max(v1.x, v2.x); v1.x = Phanes::Core::Math::Max(v1.x, v2.x);
v1.y = Phanes::Core::Math::Max(v1.y, v2.y); v1.y = Phanes::Core::Math::Max(v1.y, v2.y);
@ -435,7 +435,7 @@ namespace Phanes::Core::Math {
*/ */
template<IntType T> template<IntType T>
TIntVector3<T, false> MinV(TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2) TIntVector3<T, false>& MinV(TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2)
{ {
v1.x = Phanes::Core::Math::Min(v1.x, v2.x); v1.x = Phanes::Core::Math::Min(v1.x, v2.x);
v1.y = Phanes::Core::Math::Min(v1.y, v2.y); v1.y = Phanes::Core::Math::Min(v1.y, v2.y);
@ -453,7 +453,7 @@ namespace Phanes::Core::Math {
*/ */
template<IntType T> template<IntType T>
TIntVector3<T, false> NegateV(TIntVector3<T, false>& v1) TIntVector3<T, false>& NegateV(TIntVector3<T, false>& v1)
{ {
v1.x = -v1.x; v1.x = -v1.x;
v1.y = -v1.y; v1.y = -v1.y;
@ -462,25 +462,6 @@ namespace Phanes::Core::Math {
return v1; return v1;
} }
/**
* Performes componentwise multiplication of two vectors.
*
* @param(v1) Vector one
* @param(v2) Vector two
*
* @note result is stored in v1.
*/
template<IntType T>
TIntVector3<T, false> ScaleV(TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2)
{
v1.x *= v2.x;
v1.y *= v2.y;
v1.z *= v2.z;
return v1;
}
/** /**
* Copies v1 vector * Copies v1 vector
* *
@ -489,7 +470,7 @@ namespace Phanes::Core::Math {
*/ */
template<IntType T> template<IntType T>
TIntVector3<T, false> Set(TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2) TIntVector3<T, false>& Set(TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2)
{ {
v1 = v2; v1 = v2;
@ -506,7 +487,7 @@ namespace Phanes::Core::Math {
*/ */
template<IntType T> template<IntType T>
TIntVector3<T, false> Set(TIntVector3<T, false>& v1, T x, T y, T z) TIntVector3<T, false>& Set(TIntVector3<T, false>& v1, T x, T y, T z)
{ {
v1.x = x; v1.x = x;
v1.y = y; v1.y = y;
@ -522,7 +503,7 @@ namespace Phanes::Core::Math {
*/ */
template<IntType T> template<IntType T>
TIntVector3<T, false> SignVectorV(TIntVector3<T, false>& v1) TIntVector3<T, false>& SignVectorV(TIntVector3<T, false>& v1)
{ {
v1.x = (v1.x >= 0) ? 1 : -1; v1.x = (v1.x >= 0) ? 1 : -1;
v1.y = (v1.y >= 0) ? 1 : -1; v1.y = (v1.y >= 0) ? 1 : -1;
@ -545,7 +526,7 @@ namespace Phanes::Core::Math {
template<IntType T> template<IntType T>
T ScalarTriple(const TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2, const TIntVector3<T, false>& v3) T ScalarTriple(const TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2, const TIntVector3<T, false>& v3)
{ {
return CrossP(v1, v2) * v3; return DotP(CrossP(v1, v2), v3);
} }
/** /**
@ -559,7 +540,7 @@ namespace Phanes::Core::Math {
*/ */
template<IntType T> template<IntType T>
TIntVector3<T, false> VectorTripleV(TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2, const TIntVector3<T, false>& v3) TIntVector3<T, false>& VectorTripleV(TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2, const TIntVector3<T, false>& v3)
{ {
CrossPV(CrossPV(v1, v2), v3); CrossPV(CrossPV(v1, v2), v3);
@ -593,7 +574,8 @@ namespace Phanes::Core::Math {
template<IntType T> template<IntType T>
inline bool IsParallel(const TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2) inline bool IsParallel(const TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2)
{ {
return (abs(DotP(v1, v2)) == 1); T tmp = v1.x / v2.x;
return (tmp == (v1.y / v2.y) && tmp == (v1.z / v2.z));
} }
/** /**
@ -608,7 +590,8 @@ namespace Phanes::Core::Math {
template<IntType T> template<IntType T>
inline bool IsCoincident(const TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2) inline bool IsCoincident(const TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2)
{ {
return (DotP(v1, v2) == 1); T tmp = v1.x / v2.x;
return (tmp == (v1.y / v2.y) && tmp == (v1.z / v2.z) && tmp > -1);
} }
/** /**
@ -645,8 +628,8 @@ namespace Phanes::Core::Math {
TIntVector3<T, false> CrossP(const TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2) TIntVector3<T, false> CrossP(const TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2)
{ {
return TIntVector3<T, false>((v1.y * v2.z) - (v1.z * v2.y), return TIntVector3<T, false>((v1.y * v2.z) - (v1.z * v2.y),
(v1.z * v2.x) - (v1.x * v2.z), (v1.z * v2.x) - (v1.x * v2.z),
(v1.x * v2.y) - (v1.y * v2.x)); (v1.x * v2.y) - (v1.y * v2.x));
} }
/** /**
@ -662,8 +645,8 @@ namespace Phanes::Core::Math {
TIntVector3<T, false> Max(const TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2) TIntVector3<T, false> Max(const TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2)
{ {
return TIntVector3<T, false>((v1.x > v2.x) ? v1.x : v2.x, return TIntVector3<T, false>((v1.x > v2.x) ? v1.x : v2.x,
(v1.y > v2.y) ? v1.y : v2.y, (v1.y > v2.y) ? v1.y : v2.y,
(v1.z > v2.z) ? v1.z : v2.z); (v1.z > v2.z) ? v1.z : v2.z);
} }
/** /**
@ -679,8 +662,8 @@ namespace Phanes::Core::Math {
TIntVector3<T, false> Min(const TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2) TIntVector3<T, false> Min(const TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2)
{ {
return TIntVector3<T, false>((v1.x < v2.x) ? v1.x : v2.x, return TIntVector3<T, false>((v1.x < v2.x) ? v1.x : v2.x,
(v1.y < v2.y) ? v1.y : v2.y, (v1.y < v2.y) ? v1.y : v2.y,
(v1.z < v2.z) ? v1.z : v2.z); (v1.z < v2.z) ? v1.z : v2.z);
} }
/** /**
@ -697,21 +680,6 @@ namespace Phanes::Core::Math {
return TIntVector3<T, false>(-v1.x, -v1.y, -v1.z); return TIntVector3<T, false>(-v1.x, -v1.y, -v1.z);
} }
/**
* Multiplies vector componentwise.
*
* @param(v1) Vector one
* @param(v2) Vector two
*
* @return Vector with componentwise products
*/
template<IntType T>
TIntVector3<T, false> Scale(const TIntVector3<T, false>& v1, const TIntVector3<T, false>& v2)
{
return TIntVector3<T, false>(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z);
}
/** /**
* Gets vector triple product ((v1 x v2) x v3). * Gets vector triple product ((v1 x v2) x v3).
* *
@ -728,6 +696,12 @@ namespace Phanes::Core::Math {
return CrossP(CrossP(v1, v2), v3); return CrossP(CrossP(v1, v2), v3);
} }
template<IntType T>
TIntVector3<T, false> SignVector(const TIntVector3<T, false>& v1)
{
return TIntVector3<T, false>((v1.x >= 0) ? 1 : -1, (v1.y >= 0) ? 1 : -1, (v1.z >= 0) ? 1 : -1);
}
} // phanes::core::math::coretypes } // phanes::core::math::coretypes
#endif // !INTVECTOR3_H #endif // !INTVECTOR3_H

View File

@ -274,7 +274,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector3<T, S> operator&(TIntVector3<T, S>& v1, const TIntVector3<T, S>& v2) TIntVector3<T, S> operator&(TIntVector3<T, S>& v1, const TIntVector3<T, S>& v2)
{ {
TVector2<T, S> r; TIntVector3<T, S> r;
Detail::compute_ivec3_and<T, S>::map(r, v1, v2); Detail::compute_ivec3_and<T, S>::map(r, v1, v2);
return r; return r;
} }
@ -282,7 +282,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector3<T, S> operator&(TIntVector3<T, S>& v1, T s) TIntVector3<T, S> operator&(TIntVector3<T, S>& v1, T s)
{ {
TVector2<T, S> r; TIntVector3<T, S> r;
Detail::compute_ivec3_and<T, S>::map(r, v1, s); Detail::compute_ivec3_and<T, S>::map(r, v1, s);
return r; return r;
} }
@ -290,7 +290,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector3<T, S> operator|(TIntVector3<T, S>& v1, const TIntVector3<T, S>& v2) TIntVector3<T, S> operator|(TIntVector3<T, S>& v1, const TIntVector3<T, S>& v2)
{ {
TVector2<T, S> r; TIntVector3<T, S> r;
Detail::compute_ivec3_or<T, S>::map(r, v1, v2); Detail::compute_ivec3_or<T, S>::map(r, v1, v2);
return r; return r;
} }
@ -298,7 +298,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector3<T, S> operator|(TIntVector3<T, S>& v1, T s) TIntVector3<T, S> operator|(TIntVector3<T, S>& v1, T s)
{ {
TVector2<T, S> r; TIntVector3<T, S> r;
Detail::compute_ivec3_or<T, S>::map(r, v1, s); Detail::compute_ivec3_or<T, S>::map(r, v1, s);
return r; return r;
} }
@ -306,7 +306,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector3<T, S> operator^(TIntVector3<T, S>& v1, const TIntVector3<T, S>& v2) TIntVector3<T, S> operator^(TIntVector3<T, S>& v1, const TIntVector3<T, S>& v2)
{ {
TVector2<T, S> r; TIntVector3<T, S> r;
Detail::compute_ivec3_xor<T, S>::map(r, v1, v2); Detail::compute_ivec3_xor<T, S>::map(r, v1, v2);
return r; return r;
} }
@ -314,7 +314,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector3<T, S> operator^(TIntVector3<T, S>& v1, T s) TIntVector3<T, S> operator^(TIntVector3<T, S>& v1, T s)
{ {
TVector2<T, S> r; TIntVector3<T, S> r;
Detail::compute_ivec3_xor<T, S>::map(r, v1, s); Detail::compute_ivec3_xor<T, S>::map(r, v1, s);
return r; return r;
} }
@ -322,7 +322,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector3<T, S> operator<<(TIntVector3<T, S>& v1, const TIntVector3<T, S>& v2) TIntVector3<T, S> operator<<(TIntVector3<T, S>& v1, const TIntVector3<T, S>& v2)
{ {
TVector2<T, S> r; TIntVector3<T, S> r;
Detail::compute_ivec3_left_shift<T, S>::map(r, v1, v2); Detail::compute_ivec3_left_shift<T, S>::map(r, v1, v2);
return r; return r;
} }
@ -330,7 +330,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector3<T, S> operator<<(TIntVector3<T, S>& v1, T s) TIntVector3<T, S> operator<<(TIntVector3<T, S>& v1, T s)
{ {
TVector2<T, S> r; TIntVector3<T, S> r;
Detail::compute_ivec3_left_shift<T, S>::map(r, v1, s); Detail::compute_ivec3_left_shift<T, S>::map(r, v1, s);
return r; return r;
} }
@ -338,7 +338,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector3<T, S> operator>>(TIntVector3<T, S>& v1, const TIntVector3<T, S>& v2) TIntVector3<T, S> operator>>(TIntVector3<T, S>& v1, const TIntVector3<T, S>& v2)
{ {
TVector2<T, S> r; TIntVector3<T, S> r;
Detail::compute_ivec3_right_shift<T, S>::map(r, v1, v2); Detail::compute_ivec3_right_shift<T, S>::map(r, v1, v2);
return r; return r;
} }
@ -346,7 +346,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector3<T, S> operator>>(TIntVector3<T, S>& v1, T s) TIntVector3<T, S> operator>>(TIntVector3<T, S>& v1, T s)
{ {
TVector2<T, S> r; TIntVector3<T, S> r;
Detail::compute_ivec3_right_shift<T, S>::map(r, v1, s); Detail::compute_ivec3_right_shift<T, S>::map(r, v1, s);
return r; return r;
} }
@ -354,7 +354,7 @@ namespace Phanes::Core::Math
template<IntType T, bool S> template<IntType T, bool S>
TIntVector3<T, S> operator~(TIntVector3<T, S>& v1) TIntVector3<T, S> operator~(TIntVector3<T, S>& v1)
{ {
TVector2<T, S> r; TIntVector3<T, S> r;
Detail::compute_ivec3_bnot<T, S>::map(r, v1); Detail::compute_ivec3_bnot<T, S>::map(r, v1);
return r; return r;
} }

View File

@ -52,6 +52,20 @@ namespace Phanes::Core::Math {
* Specific instantiation of forward declarations. * Specific instantiation of forward declarations.
*/ */
// IntVetor2
typedef TIntVector2<int, false> IntVector2;
typedef TIntVector2<int, false> Vector2i;
typedef TIntVector2<long, false> LongVector2;
typedef TIntVector2<long, false> Vector2l;
// IntVetor3
typedef TIntVector3<int, false> IntVector3;
typedef TIntVector3<int, false> Vector3i;
typedef TIntVector3<long, false> LongVector3;
typedef TIntVector3<long, false> Vector3l;
// Vector2 // Vector2
typedef TVector2<float, false> Vector2; typedef TVector2<float, false> Vector2;