Added min(vector, vector) and max(vector,vector) functions

This commit is contained in:
Kearwood Kip Gilbert
2018-03-28 12:59:33 -07:00
parent 7fc321ebb8
commit 20d341227d
8 changed files with 47 additions and 3 deletions

View File

@@ -30,6 +30,7 @@
//
#include "../include/kraken-math.h"
#include "krhelpers.h"
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;
}
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
{
// Comparison operators are implemented to allow insertion into sorted containers such as std::set