Added min(vector, vector) and max(vector,vector) functions
This commit is contained in:
@@ -94,8 +94,9 @@ public:
|
|||||||
static Vector2 Normalize(const Vector2 &v);
|
static Vector2 Normalize(const Vector2 &v);
|
||||||
|
|
||||||
static float Cross(const Vector2 &v1, const Vector2 &v2);
|
static float Cross(const Vector2 &v1, const Vector2 &v2);
|
||||||
|
|
||||||
static float Dot(const Vector2 &v1, const Vector2 &v2);
|
static float Dot(const Vector2 &v1, const Vector2 &v2);
|
||||||
|
static Vector2 Min(const Vector2 &v1, const Vector2 &v2);
|
||||||
|
static Vector2 Max(const Vector2 &v1, const Vector2 &v2);
|
||||||
static Vector2 Min();
|
static Vector2 Min();
|
||||||
static Vector2 Max();
|
static Vector2 Max();
|
||||||
static Vector2 Zero();
|
static Vector2 Zero();
|
||||||
|
|||||||
@@ -95,8 +95,10 @@ public:
|
|||||||
static Vector2i Normalize(const Vector2i &v);
|
static Vector2i Normalize(const Vector2i &v);
|
||||||
|
|
||||||
static int Cross(const Vector2i &v1, const Vector2i &v2);
|
static int Cross(const Vector2i &v1, const Vector2i &v2);
|
||||||
|
|
||||||
static int Dot(const Vector2i &v1, const Vector2i &v2);
|
static int Dot(const Vector2i &v1, const Vector2i &v2);
|
||||||
|
static Vector2i Min(const Vector2i &v1, const Vector2i &v2);
|
||||||
|
static Vector2i Max(const Vector2i &v1, const Vector2i &v2);
|
||||||
|
|
||||||
static Vector2i Min();
|
static Vector2i Min();
|
||||||
static Vector2i Max();
|
static Vector2i Max();
|
||||||
static Vector2i Zero();
|
static Vector2i Zero();
|
||||||
|
|||||||
@@ -115,8 +115,10 @@ public:
|
|||||||
static Vector3 Normalize(const Vector3 &v);
|
static Vector3 Normalize(const Vector3 &v);
|
||||||
|
|
||||||
static Vector3 Cross(const Vector3 &v1, const Vector3 &v2);
|
static Vector3 Cross(const Vector3 &v1, const Vector3 &v2);
|
||||||
|
|
||||||
static float Dot(const Vector3 &v1, const Vector3 &v2);
|
static float Dot(const Vector3 &v1, const Vector3 &v2);
|
||||||
|
static Vector3 Min(const Vector3 &v1, const Vector3 &v2);
|
||||||
|
static Vector3 Max(const Vector3 &v1, const Vector3 &v2);
|
||||||
|
|
||||||
static Vector3 Min();
|
static Vector3 Min();
|
||||||
static Vector3 Max();
|
static Vector3 Max();
|
||||||
static Vector3 Zero();
|
static Vector3 Zero();
|
||||||
|
|||||||
@@ -90,6 +90,9 @@ public:
|
|||||||
static Vector4 Normalize(const Vector4 &v);
|
static Vector4 Normalize(const Vector4 &v);
|
||||||
|
|
||||||
static float Dot(const Vector4 &v1, const Vector4 &v2);
|
static float Dot(const Vector4 &v1, const Vector4 &v2);
|
||||||
|
static Vector4 Min(const Vector4 &v1, const Vector4 &v2);
|
||||||
|
static Vector4 Max(const Vector4 &v1, const Vector4 &v2);
|
||||||
|
|
||||||
static Vector4 Min();
|
static Vector4 Min();
|
||||||
static Vector4 Max();
|
static Vector4 Max();
|
||||||
static Vector4 Zero();
|
static Vector4 Zero();
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/kraken-math.h"
|
||||||
|
#include "krhelpers.h"
|
||||||
|
|
||||||
namespace kraken {
|
namespace kraken {
|
||||||
|
|
||||||
@@ -259,4 +260,12 @@ float Vector2::Dot(const Vector2 &v1, const Vector2 &v2) {
|
|||||||
return v1.x * v2.x + v1.y * v2.y;
|
return v1.x * v2.x + v1.y * v2.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2 Vector2::Min(const Vector2 &v1, const Vector2 &v2) {
|
||||||
|
return Vector2::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y));
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2 Vector2::Max(const Vector2 &v1, const Vector2 &v2) {
|
||||||
|
return Vector2::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y));
|
||||||
|
}
|
||||||
|
|
||||||
} // namepsace kraken
|
} // namepsace kraken
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/kraken-math.h"
|
||||||
|
#include "krhelpers.h"
|
||||||
|
|
||||||
namespace kraken {
|
namespace kraken {
|
||||||
|
|
||||||
@@ -253,4 +254,12 @@ int Vector2i::Dot(const Vector2i &v1, const Vector2i &v2) {
|
|||||||
return v1.x * v2.x + v1.y * v2.y;
|
return v1.x * v2.x + v1.y * v2.y;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2i Vector2i::Min(const Vector2i &v1, const Vector2i &v2) {
|
||||||
|
return Vector2i::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y));
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector2i Vector2i::Max(const Vector2i &v1, const Vector2i &v2) {
|
||||||
|
return Vector2i::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y));
|
||||||
|
}
|
||||||
|
|
||||||
} // namepsace kraken
|
} // namepsace kraken
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/kraken-math.h"
|
||||||
|
#include "krhelpers.h"
|
||||||
|
|
||||||
namespace kraken {
|
namespace kraken {
|
||||||
|
|
||||||
@@ -416,6 +417,14 @@ float Vector3::Dot(const Vector3 &v1, const Vector3 &v2) {
|
|||||||
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
|
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector3 Vector3::Min(const Vector3 &v1, const Vector3 &v2) {
|
||||||
|
return Vector3::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y), KRMIN(v1.z, v2.z));
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector3 Vector3::Max(const Vector3 &v1, const Vector3 &v2) {
|
||||||
|
return Vector3::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y), KRMAX(v1.z, v2.z));
|
||||||
|
}
|
||||||
|
|
||||||
bool Vector3::operator >(const Vector3& b) const
|
bool Vector3::operator >(const Vector3& b) const
|
||||||
{
|
{
|
||||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "../include/kraken-math.h"
|
#include "../include/kraken-math.h"
|
||||||
|
#include "krhelpers.h"
|
||||||
|
|
||||||
namespace kraken {
|
namespace kraken {
|
||||||
|
|
||||||
@@ -312,6 +313,14 @@ float Vector4::Dot(const Vector4 &v1, const Vector4 &v2) {
|
|||||||
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w;
|
return v1.x * v2.x + v1.y * v2.y + v1.z * v2.z + v1.w * v2.w;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector4 Vector4::Min(const Vector4 &v1, const Vector4 &v2) {
|
||||||
|
return Vector4::Create(KRMIN(v1.x, v2.x), KRMIN(v1.y, v2.y), KRMIN(v1.z, v2.z), KRMIN(v1.w, v2.w));
|
||||||
|
}
|
||||||
|
|
||||||
|
Vector4 Vector4::Max(const Vector4 &v1, const Vector4 &v2) {
|
||||||
|
return Vector4::Create(KRMAX(v1.x, v2.x), KRMAX(v1.y, v2.y), KRMAX(v1.z, v2.z), KRMAX(v1.w, v2.w));
|
||||||
|
}
|
||||||
|
|
||||||
bool Vector4::operator >(const Vector4& b) const
|
bool Vector4::operator >(const Vector4& b) const
|
||||||
{
|
{
|
||||||
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
// Comparison operators are implemented to allow insertion into sorted containers such as std::set
|
||||||
|
|||||||
Reference in New Issue
Block a user