Skip to content

Commit 96e4e1c

Browse files
committed
added new method added concept for mat type
1 parent 872dbe1 commit 96e4e1c

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

include/omath/Mat.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ namespace omath
2222
COLUMN_MAJOR
2323
};
2424

25+
26+
template<typename M1, typename M2>
27+
concept MatTemplateEqual =
28+
(M1::rows == M2::rows) && (M1::columns == M2::columns) &&
29+
std::is_same_v<typename M1::value_type, typename M2::value_type> &&
30+
(M1::store_type == M2::store_type);
31+
2532
template<size_t Rows = 0, size_t Columns = 0, class Type = float, MatStoreType StoreType = MatStoreType::ROW_MAJOR>
2633
requires std::is_arithmetic_v<Type>
2734
class Mat final

include/omath/Vector3.hpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "omath/Vector2.hpp"
1010
#include "omath/Angle.hpp"
1111
#include <expected>
12+
#include <immintrin.h>
1213

1314

1415
namespace omath
@@ -228,14 +229,22 @@ namespace omath
228229
return Angle<float, 0.f, 180.f, AngleFlags::Clamped>::FromRadians(std::acos(Dot(other) / bottom));
229230
}
230231

232+
[[nodiscard]] bool IsPerpendicular(const Vector3& other) const
233+
{
234+
if (const auto angle = AngleBetween(other))
235+
return angle->AsDegrees() == 90.f;
236+
237+
return false;
238+
}
239+
231240
[[nodiscard]] constexpr float Sum2D() const
232241
{
233242
return Vector2::Sum();
234243
}
235244

236245
[[nodiscard]] Vector3 ViewAngleTo(const Vector3& other) const;
237246

238-
[[nodiscard]] std::tuple<float, float, float> AsTuple() const
247+
[[nodiscard]] constexpr std::tuple<float, float, float> AsTuple() const
239248
{
240249
return std::make_tuple(x, y, z);
241250
}

tests/general/UnitTestVector3.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,12 @@ TEST_F(UnitTestVector3, AngleBeatween)
395395
EXPECT_FALSE(Vector3(0.0f, 0.0f, 0.0f).AngleBetween({0.0f, 0.0f, 1.0f}).has_value());
396396
}
397397

398+
TEST_F(UnitTestVector3, IsPerpendicular)
399+
{
400+
EXPECT_EQ(Vector3(0.0f, 0.0f, 1.0f).IsPerpendicular({1, 0 ,0}), true);
401+
EXPECT_EQ(Vector3(0.0f, 0.0f, 1.0f).IsPerpendicular({0.0f, 0.0f, 1.0f}), false);
402+
EXPECT_FALSE(Vector3(0.0f, 0.0f, 0.0f).IsPerpendicular({0.0f, 0.0f, 1.0f}));
403+
}
398404

399405
// Static assertions (compile-time checks)
400406
static_assert(Vector3(1.0f, 2.0f, 3.0f).LengthSqr() == 14.0f, "LengthSqr should be 14");

0 commit comments

Comments
 (0)