Add Mod for vectors

This commit is contained in:
Wojtek Figat
2022-07-31 19:05:36 +02:00
parent 3b52914416
commit 17b3434342
4 changed files with 20 additions and 0 deletions

View File

@@ -157,6 +157,11 @@ namespace Math
return value < 0 ? -value : value;
}
static FORCE_INLINE int32 Mod(const int32 a, const int32 b)
{
return (int32)fmodf((float)a, (float)b);
}
static FORCE_INLINE float Mod(const float a, const float b)
{
return fmodf(a, b);

View File

@@ -457,6 +457,11 @@ public:
return Vector2Base(a.X > b.X ? a.X : b.X, a.Y > b.Y ? a.Y : b.Y);
}
static Vector2Base Mod(const Vector2Base& a, const Vector2Base& b)
{
return Vector2Base(Math::Mod(a.X, b.X), Math::Mod(a.Y, b.Y));
}
static Vector2Base Floor(const Vector2Base& v)
{
return Vector2Base(Math::Floor(v.X), Math::Floor(v.Y));

View File

@@ -512,6 +512,11 @@ public:
return Vector3Base(a.X > b.X ? a.X : b.X, a.Y > b.Y ? a.Y : b.Y, a.Z > b.Z ? a.Z : b.Z);
}
static Vector3Base Mod(const Vector3Base& a, const Vector3Base& b)
{
return Vector3Base(Math::Mod(a.X, b.X), Math::Mod(a.Y, b.Y), Math::Mod(a.Z, b.Z));
}
static Vector3Base Floor(const Vector3Base& v)
{
return Vector3Base(Math::Floor(v.X), Math::Floor(v.Y), Math::Floor(v.Z));

View File

@@ -423,6 +423,11 @@ public:
}
public:
static Vector4Base Mod(const Vector4Base& a, const Vector4Base& b)
{
return Vector4Base(Math::Mod(a.X, b.X), Math::Mod(a.Y, b.Y), Math::Mod(a.Z, b.Z), Math::Mod(a.W, b.W));
}
static Vector4Base Floor(const Vector4Base& v)
{
return Vector4Base(Math::Floor(v.X), Math::Floor(v.Y), Math::Floor(v.Z), Math::Floor(v.W));