Implement more static constants for Vector3
All checks were successful
Build Docs With Doxygen / Explore-Gitea-Actions (push) Successful in 1m7s

This commit is contained in:
2024-05-10 14:59:57 -04:00
parent 80a6bf7a14
commit f72bb0de9f
2 changed files with 53 additions and 0 deletions

View File

@@ -17,16 +17,66 @@ public:
public:
enum {Dimensions = 3};
public:
/// Specifies a compile-time constant Vector3 with value (0,0,0).
/** @note Due to static data initialization order being undefined in C++, do NOT use this
member to initialize other static data in other compilation units! */
static const Vector3 Zero;
/// Specifies a compile-time constant Vector3 with value (1,1,1).
/** @note Due to static data initialization order being undefined in C++, do NOT use this
member to initialize other static data in other compilation units! */
static const Vector3 One;
/// Specifies a compile-time constant Vector3 with value (0,1,0).
/** @note Due to static data initialization order being undefined in C++, do NOT use this
member to initialize other static data in other compilation units! */
static const Vector3 Up;
/// Specifies a compile-time constant Vector3 with value (0,-1,0).
/** @note Due to static data initialization order being undefined in C++, do NOT use this
member to initialize other static data in other compilation units! */
static const Vector3 Down;
/// Specifies a compile-time constant Vector3 with value (-1,0,0).
/** @note Due to static data initialization order being undefined in C++, do NOT use this
member to initialize other static data in other compilation units! */
static const Vector3 Left;
/// Specifies a compile-time constant Vector3 with value (1,0,0).
/** @note Due to static data initialization order being undefined in C++, do NOT use this
member to initialize other static data in other compilation units! */
static const Vector3 Right;
/// Specifies a compile-time constant Vector3 with value (0,0,-1).
/** @note Due to static data initialization order being undefined in C++, do NOT use this
member to initialize other static data in other compilation units! */
static const Vector3 Forward;
/// Specifies a compile-time constant Vector3 with value (0,0,1).
/** @note Due to static data initialization order being undefined in C++, do NOT use this
member to initialize other static data in other compilation units! */
static const Vector3 Backward;
/// Specifies a compile-time constant Vector3 with value (NAN, NAN, NAN).
/** For this constant, aeach element has the value of quet NaN, or Not-A-Number.
@note Never compare a Vector3 to this value! Due to how IEEE floats work, "nan == nan" returns false!
That is, nothing is equal to NaN, not even NaN itself!
@note Due to static data initialization order being undefined in C++, do NOT use this
member data to intialize other static data in other compilation units! */
static const Vector3 NaN;
/// Specifies a compile-time constant Vector3 with value (+infinity, +infinity, +infinity).
/** @note Due to static data initialization order being undefined in C++, do NOT use this
member to initialize other static data in other compilation units! */
static const Vector3 Infinity;
/// Specifies a compile-time constant Vector3 with value (-infinity, -infinity, -infinity).
/** @note Due to static data initialization order being undefined in C++, do NOT use this
member to initialize other static data in other compilation units! */
static const Vector3 NegativeInfinity;
/// Specifies a compile-time constant Vector3 with value (1,1,1).
/** @note Due to static data initialization order being undefined in C++, do NOT use this
member to initialize other static data in other compilation units! */
static const Vector3 UnitX;
/// Specifies a compile-time constant Vector3 with value (1,1,1).
/** @note Due to static data initialization order being undefined in C++, do NOT use this
member to initialize other static data in other compilation units! */
static const Vector3 UnitY;
/// Specifies a compile-time constant Vector3 with value (1,1,1).
/** @note Due to static data initialization order being undefined in C++, do NOT use this
member to initialize other static data in other compilation units! */
static const Vector3 UnitZ;
public:
/// The default constructor does not initialize any members of this class.

View File

@@ -15,6 +15,9 @@ namespace J3ML::LinearAlgebra {
const Vector3 Vector3::NaN = {NAN, NAN, NAN};
const Vector3 Vector3::Infinity = {INFINITY, INFINITY, INFINITY};
const Vector3 Vector3::NegativeInfinity = {-INFINITY, -INFINITY, -INFINITY};
const Vector3 Vector3::UnitX = {1,0,0};
const Vector3 Vector3::UnitY = {0,1,0};
const Vector3 Vector3::UnitZ = {0,0,1};
Vector3 Vector3::operator+(const Vector3& rhs) const
{