1
0
forked from josh/j3ml

Implement Vector2Tests

This commit is contained in:
2023-12-29 01:02:57 -05:00
parent fd4cc4723b
commit d2960b1dc4
9 changed files with 242 additions and 178 deletions

View File

@@ -2,6 +2,7 @@
#include <J3ML/LinearAlgebra/Vector3.h>
#include <cstddef>
#include <cstdlib>
namespace LinearAlgebra {
@@ -18,14 +19,7 @@ public:
Vector3(Vector3&&) = default; // Move Constructor
Vector3& operator=(const Vector3& rhs);
float GetX() const;
float GetY() const;
float GetZ() const;
#if MUTABLE
void SetX(float newX) { x = newX;}
void SetY(float newY) { y = newY;}
void SetZ(float newZ) { z = newZ;}
#endif
static const Vector3 Zero;
static const Vector3 Up;
static const Vector3 Down;
@@ -35,15 +29,21 @@ public:
static const Vector3 Backward;
static const Vector3 NaN;
float operator[](std::size_t index) const;
float GetX() const;
float GetY() const;
float GetZ() const;
void SetX(float newX);
void SetY(float newY);
void SetZ(float newZ);
bool IsWithinMarginOfError(const Vector3& rhs, float margin=0.001f) const;
bool IsNormalized(float epsilonSq = 1e-5f) const;
bool IsZero(float epsilonSq = 1e-6f) const;
bool IsFinite() const;
bool IsPerpendicular(const Vector3& other, float epsilonSq=1e-5f) const;
float operator[](std::size_t index) const;
bool operator == (const Vector3& rhs) const;
bool operator != (const Vector3& rhs) const;
@@ -68,7 +68,10 @@ public:
// Returns the length of the vector, which is sqrt(x^2 + y^2 + z^2)
float Magnitude() const;
static float Magnitude(const Vector3& of);
static float Magnitude(const Vector3& of)
{
}
// Returns a float value equal to the magnitudes of the two vectors multiplied together and then multiplied by the cosine of the angle between them.
// For normalized vectors, dot returns 1 if they point in exactly the same direction,
@@ -127,14 +130,9 @@ public:
public:
#if MUTABLE
float x = 0;
float y = 0;
float z = 0;
#else
float x = 0;
float y = 0;
float z = 0;
#endif
};
}