diff --git a/Engine/Source/Runtime/Core/public/Math/Detail/IntVector4Decl.inl b/Engine/Source/Runtime/Core/public/Math/Detail/IntVector4Decl.inl index 7ef1112..a66118b 100644 --- a/Engine/Source/Runtime/Core/public/Math/Detail/IntVector4Decl.inl +++ b/Engine/Source/Runtime/Core/public/Math/Detail/IntVector4Decl.inl @@ -77,8 +77,8 @@ namespace Phanes::Core::Math::Detail { v1.x = x; v1.y = y; - v1.y = z; - v1.y = w; + v1.z = z; + v1.w = w; } @@ -176,12 +176,10 @@ namespace Phanes::Core::Math::Detail static constexpr void map(Phanes::Core::Math::TIntVector4& r, const Phanes::Core::Math::TIntVector4& v1, T s) { - s = (T)1.0 / s; - - r.x = v1.x * s; - r.y = v1.y * s; - r.z = v1.z * s; - r.w = v1.w * s; + r.x = v1.x / s; + r.y = v1.y / s; + r.z = v1.z / s; + r.w = v1.w / s; } }; diff --git a/Engine/Source/Runtime/Core/public/Math/IntVector2.hpp b/Engine/Source/Runtime/Core/public/Math/IntVector2.hpp index 84ebf9f..25db1a7 100644 --- a/Engine/Source/Runtime/Core/public/Math/IntVector2.hpp +++ b/Engine/Source/Runtime/Core/public/Math/IntVector2.hpp @@ -553,41 +553,6 @@ namespace Phanes::Core::Math { return (Abs(DotP(v1, v2)) == 0); } - /** - * Tests if 2 vectors are parallel to each other. (Angle is close to zero.) - * - * @param(v1) Vector one - * @param(v2) Vector two - * - * @return true if parallel, false if not - * - * @note Requires v1 and v2 to be normal vectors. - */ - - template - inline bool IsParallel(const TIntVector2& v1, const TIntVector2& v2) - { - return ((v1.x / v2.x) == (v1.y / v2.y)); - } - - /** - * Tests if 2 vectors are coincident. (Are parallel and point in the same direction.) - * - * @param(v1) Vector one - * @param(v2) Vector two - * - * @return true if coincident, false if not - * - * @note Requires v1 and v2 to be normal vectors. - */ - - template - inline bool IsCoincident(const TIntVector2& v1, const TIntVector2& v2) - { - T tmp = v1.x / v2.x; - return (tmp == (v1.y / v2.y) && tmp > -1); - } - /** * Gets outer product of to vectors. * diff --git a/Engine/Source/Runtime/Core/public/Math/IntVector3.hpp b/Engine/Source/Runtime/Core/public/Math/IntVector3.hpp index 4d37be9..3582201 100644 --- a/Engine/Source/Runtime/Core/public/Math/IntVector3.hpp +++ b/Engine/Source/Runtime/Core/public/Math/IntVector3.hpp @@ -547,6 +547,17 @@ namespace Phanes::Core::Math { return v1; } + template + TIntVector3& GetPerpendicular(TIntVector3& v1) + { + T y = v1.y; + v1.x = 0; + v1.y = v1.z; + v1.z = -y; + + return v1; + } + /** * Tests whether two vectors are perpendicular. * @@ -562,38 +573,6 @@ namespace Phanes::Core::Math { return (DotP(v1, v2) == 0); } - /** - * Tests whether two vectors are parallel. - * - * @param(v1) Vector one - * @param(v2) Vector two - * - * @return True if parallel, false if not. - */ - - template - inline bool IsParallel(const TIntVector3& v1, const TIntVector3& v2) - { - T tmp = v1.x / v2.x; - return (tmp == (v1.y / v2.y) && tmp == (v1.z / v2.z)); - } - - /** - * Tests whether two vectors are coincident (Parallel and point in same direction). - * - * @param(v1) Vector one - * @param(v2) Vector two - * - * @return True if coincident, false if not. - */ - - template - inline bool IsCoincident(const TIntVector3& v1, const TIntVector3& v2) - { - T tmp = v1.x / v2.x; - return (tmp == (v1.y / v2.y) && tmp == (v1.z / v2.z) && tmp > -1); - } - /** * Tests if three vectors are coplanar * diff --git a/Engine/Source/Runtime/Core/public/Math/IntVector4.hpp b/Engine/Source/Runtime/Core/public/Math/IntVector4.hpp index e14f1ca..61e1168 100644 --- a/Engine/Source/Runtime/Core/public/Math/IntVector4.hpp +++ b/Engine/Source/Runtime/Core/public/Math/IntVector4.hpp @@ -573,6 +573,8 @@ namespace Phanes::Core::Math { v1.y = -v1.y; v1.z = -v1.z; v1.w = -v1.w; + + return v1; } /// @@ -612,6 +614,8 @@ namespace Phanes::Core::Math { v1.y = (v1.y > 0) ? 1 : -1; v1.z = (v1.z > 0) ? 1 : -1; v1.w = (v1.w > 0) ? 1 : -1; + + return v1; } /// @@ -624,33 +628,7 @@ namespace Phanes::Core::Math { template inline bool IsPerpendicular(const TIntVector4& v1, const TIntVector4& v2) { - return (abs(DotP(v1, v2)) = 0); - } - - /// - /// Test if two vectors are parallel. - /// - /// Type of vector - /// - /// - /// True if parralel. - template - inline bool IsParallel(const TIntVector4& v1, const TIntVector4& v2) - { - return (abs(DotP(v1, v2)) = 1); - } - - /// - /// Test if two vectors are parallel. - /// - /// - /// - /// - /// - template - inline bool IsCoincident(const TIntVector4& v1, const TIntVector4& v2) - { - return (DotP(v1, v2) = 1); + return (abs(DotP(v1, v2)) == 0); } } // phanes::core::math::coretypes diff --git a/Engine/Source/Runtime/Core/public/Math/IntVector4.inl b/Engine/Source/Runtime/Core/public/Math/IntVector4.inl index e095540..fe78836 100644 --- a/Engine/Source/Runtime/Core/public/Math/IntVector4.inl +++ b/Engine/Source/Runtime/Core/public/Math/IntVector4.inl @@ -273,7 +273,7 @@ namespace Phanes::Core::Math template TIntVector4 operator&(TIntVector4& v1, const TIntVector4& v2) { - TVector2 r; + TIntVector4 r; Detail::compute_ivec4_and::map(r, v1, v2); return r; } @@ -281,7 +281,7 @@ namespace Phanes::Core::Math template TIntVector4 operator&(TIntVector4& v1, T s) { - TVector2 r; + TIntVector4 r; Detail::compute_ivec4_and::map(r, v1, s); return r; } @@ -289,7 +289,7 @@ namespace Phanes::Core::Math template TIntVector4 operator|(TIntVector4& v1, const TIntVector4& v2) { - TVector2 r; + TIntVector4 r; Detail::compute_ivec4_or::map(r, v1, v2); return r; } @@ -297,7 +297,7 @@ namespace Phanes::Core::Math template TIntVector4 operator|(TIntVector4& v1, T s) { - TVector2 r; + TIntVector4 r; Detail::compute_ivec4_or::map(r, v1, s); return r; } @@ -305,7 +305,7 @@ namespace Phanes::Core::Math template TIntVector4 operator^(TIntVector4& v1, const TIntVector4& v2) { - TVector2 r; + TIntVector4 r; Detail::compute_ivec4_xor::map(r, v1, v2); return r; } @@ -313,7 +313,7 @@ namespace Phanes::Core::Math template TIntVector4 operator^(TIntVector4& v1, T s) { - TVector2 r; + TIntVector4 r; Detail::compute_ivec4_xor::map(r, v1, s); return r; } @@ -321,7 +321,7 @@ namespace Phanes::Core::Math template TIntVector4 operator<<(TIntVector4& v1, const TIntVector4& v2) { - TVector2 r; + TIntVector4 r; Detail::compute_ivec4_left_shift::map(r, v1, v2); return r; } @@ -329,7 +329,7 @@ namespace Phanes::Core::Math template TIntVector4 operator<<(TIntVector4& v1, T s) { - TVector2 r; + TIntVector4 r; Detail::compute_ivec4_left_shift::map(r, v1, s); return r; } @@ -337,7 +337,7 @@ namespace Phanes::Core::Math template TIntVector4 operator>>(TIntVector4& v1, const TIntVector4& v2) { - TVector2 r; + TIntVector4 r; Detail::compute_ivec4_right_shift::map(r, v1, v2); return r; } @@ -345,7 +345,7 @@ namespace Phanes::Core::Math template TIntVector4 operator>>(TIntVector4& v1, T s) { - TVector2 r; + TIntVector4 r; Detail::compute_ivec4_right_shift::map(r, v1, s); return r; } @@ -353,7 +353,7 @@ namespace Phanes::Core::Math template TIntVector4 operator~(TIntVector4& v1) { - TVector2 r; + TIntVector4 r; Detail::compute_ivec4_bnot::map(r, v1); return r; } diff --git a/Engine/Source/Runtime/Core/public/Math/MathFwd.h b/Engine/Source/Runtime/Core/public/Math/MathFwd.h index d880a64..5b511c6 100644 --- a/Engine/Source/Runtime/Core/public/Math/MathFwd.h +++ b/Engine/Source/Runtime/Core/public/Math/MathFwd.h @@ -66,6 +66,14 @@ namespace Phanes::Core::Math { typedef TIntVector3 LongVector3; typedef TIntVector3 Vector3l; + + // IntVetor4 + + typedef TIntVector4 IntVector4; + typedef TIntVector4 Vector4i; + typedef TIntVector4 LongVector4; + typedef TIntVector4 Vector4l; + // Vector2 typedef TVector2 Vector2;