Implement by-Reference operators
This commit is contained in:
@@ -6,9 +6,6 @@
|
||||
namespace J3ML::LinearAlgebra {
|
||||
using namespace J3ML;
|
||||
|
||||
|
||||
|
||||
|
||||
/// A 2D (x, y) ordered pair.
|
||||
class Vector2 {
|
||||
public:
|
||||
@@ -16,6 +13,7 @@ namespace J3ML::LinearAlgebra {
|
||||
Vector2();
|
||||
/// Constructs a new Vector2 with the value (X, Y)
|
||||
Vector2(float X, float Y);
|
||||
Vector2(float* xyPtr);
|
||||
Vector2(const Vector2& rhs); // Copy Constructor
|
||||
//Vector2(Vector2&&) = default; // Move Constructor
|
||||
|
||||
@@ -31,6 +29,11 @@ namespace J3ML::LinearAlgebra {
|
||||
void SetX(float newX);
|
||||
void SetY(float newY);
|
||||
|
||||
float* ptr()
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
Vector2 Abs() const;
|
||||
|
||||
bool IsWithinMarginOfError(const Vector2& rhs, float margin=0.001f) const;
|
||||
@@ -39,7 +42,8 @@ namespace J3ML::LinearAlgebra {
|
||||
bool IsZero(float epsilonSq = 1e-6f) const;
|
||||
bool IsPerpendicular(const Vector2& other, float epsilonSq=1e-5f) const;
|
||||
|
||||
float operator[](std::size_t index);
|
||||
float operator[](std::size_t index) const;
|
||||
float &operator[](std::size_t index);
|
||||
bool operator == (const Vector2& rhs) const;
|
||||
bool operator != (const Vector2& rhs) const;
|
||||
|
||||
@@ -74,10 +78,6 @@ namespace J3ML::LinearAlgebra {
|
||||
static float Magnitude(const Vector2& of);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
bool IsFinite() const;
|
||||
static bool IsFinite(const Vector2& v);
|
||||
|
||||
|
@@ -32,6 +32,11 @@ public:
|
||||
static const Vector3 Infinity;
|
||||
static const Vector3 NegativeInfinity;
|
||||
|
||||
float* ptr()
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
static void Orthonormalize(Vector3& a, Vector3& b)
|
||||
{
|
||||
a = a.Normalize();
|
||||
@@ -79,6 +84,7 @@ public:
|
||||
bool IsPerpendicular(const Vector3& other, float epsilonSq=1e-5f) const;
|
||||
|
||||
float operator[](std::size_t index) const;
|
||||
float &operator[](std::size_t index);
|
||||
bool operator == (const Vector3& rhs) const;
|
||||
bool operator != (const Vector3& rhs) const;
|
||||
|
||||
|
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <J3ML/LinearAlgebra.h>
|
||||
|
||||
|
||||
namespace J3ML::LinearAlgebra {
|
||||
class Vector4 {
|
||||
public:
|
||||
@@ -16,6 +15,11 @@ namespace J3ML::LinearAlgebra {
|
||||
Vector4(Vector4&& move) = default;
|
||||
Vector4& operator=(const Vector4& rhs);
|
||||
|
||||
float* ptr()
|
||||
{
|
||||
return &x;
|
||||
}
|
||||
|
||||
float GetX() const;
|
||||
float GetY() const;
|
||||
float GetZ() const;
|
||||
|
Reference in New Issue
Block a user