1
0
forked from josh/j3ml

Implement float * Vector3 operator

This commit is contained in:
2024-02-06 16:34:13 -05:00
parent cb5e6b4f99
commit e18a2634de
2 changed files with 15 additions and 0 deletions

View File

@@ -29,6 +29,8 @@ public:
static const Vector3 Forward;
static const Vector3 Backward;
static const Vector3 NaN;
static const Vector3 Infinity;
static const Vector3 NegativeInfinity;
static void Orthonormalize(Vector3& a, Vector3& b)
{
@@ -37,6 +39,8 @@ public:
b = b.Normalize();
}
Vector3 Abs() const;
/// Returns the DirectionVector for a given angle.
static Vector3 Direction(const Vector3 &rhs) ;
@@ -179,4 +183,9 @@ public:
float y = 0;
float z = 0;
};
static Vector3 operator*(float lhs, const Vector3& rhs)
{
return rhs * lhs;
}
}

View File

@@ -15,6 +15,8 @@ namespace J3ML::LinearAlgebra {
const Vector3 Vector3::Forward = {0, 0, -1};
const Vector3 Vector3::Backward = {0, 0, 1};
const Vector3 Vector3::NaN = {NAN, NAN, NAN};
const Vector3 Vector3::Infinity = {INFINITY, INFINITY, INFINITY};
const Vector3 Vector3::NegativeInfinity = {-INFINITY, -INFINITY, -INFINITY};
Vector3 Vector3::operator+(const Vector3& rhs) const
{
@@ -308,5 +310,9 @@ namespace J3ML::LinearAlgebra {
return {x, y, z};
}
Vector3 Vector3::Abs() const {
return {std::abs(x), std::abs(y), std::abs(z)};
}
}