Moved everything in namespace Leonetienne::Eule
This commit is contained in:
parent
3c8391d9ce
commit
be63652df6
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Vector3.h"
|
#include "Vector3.h"
|
||||||
|
|
||||||
namespace Eule
|
namespace Leonetienne::Eule
|
||||||
{
|
{
|
||||||
/** Abstract class of a collider domain.
|
/** Abstract class of a collider domain.
|
||||||
* Specializations describe a shape in 3d space, and provide implementations of the methods below,
|
* Specializations describe a shape in 3d space, and provide implementations of the methods below,
|
||||||
|
@ -2,14 +2,16 @@
|
|||||||
|
|
||||||
// Pretty sure the compiler will optimize these calculations out...
|
// Pretty sure the compiler will optimize these calculations out...
|
||||||
|
|
||||||
//! Pi up to 50 decimal places
|
namespace Leonetienne::Eule {
|
||||||
static constexpr double PI = 3.14159265358979323846264338327950288419716939937510;
|
//! Pi up to 50 decimal places
|
||||||
|
static constexpr double PI = 3.14159265358979323846264338327950288419716939937510;
|
||||||
|
|
||||||
//! Pi divided by two
|
//! Pi divided by two
|
||||||
static constexpr double HALF_PI = 1.57079632679489661923132169163975144209858469968755;
|
static constexpr double HALF_PI = 1.57079632679489661923132169163975144209858469968755;
|
||||||
|
|
||||||
//! Factor to convert degrees to radians
|
//! Factor to convert degrees to radians
|
||||||
static constexpr double Deg2Rad = 0.0174532925199432957692369076848861271344287188854172222222222222;
|
static constexpr double Deg2Rad = 0.0174532925199432957692369076848861271344287188854172222222222222;
|
||||||
|
|
||||||
//! Factor to convert radians to degrees
|
//! Factor to convert radians to degrees
|
||||||
static constexpr double Rad2Deg = 57.295779513082320876798154814105170332405472466564427711013084788;
|
static constexpr double Rad2Deg = 57.295779513082320876798154814105170332405472466564427711013084788;
|
||||||
|
}
|
||||||
|
@ -2,10 +2,9 @@
|
|||||||
#include "Constants.h"
|
#include "Constants.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
using namespace Eule;
|
namespace Leonetienne::Eule {
|
||||||
|
|
||||||
int Math::Mod(const int numerator, const int denominator)
|
int Math::Mod(const int numerator, const int denominator) {
|
||||||
{
|
|
||||||
if (denominator == 0)
|
if (denominator == 0)
|
||||||
throw std::logic_error("Division by zero");
|
throw std::logic_error("Division by zero");
|
||||||
|
|
||||||
@ -21,9 +20,9 @@ int Math::Mod(const int numerator, const int denominator)
|
|||||||
|
|
||||||
// Else: generalized formula
|
// Else: generalized formula
|
||||||
return (denominator + (numerator % denominator)) % denominator;
|
return (denominator + (numerator % denominator)) % denominator;
|
||||||
}
|
}
|
||||||
|
|
||||||
double Math::Oscillate(const double a, const double b, const double counter, const double speed)
|
double Math::Oscillate(const double a, const double b, const double counter, const double speed) {
|
||||||
{
|
|
||||||
return (sin(counter * speed * PI - HALF_PI) * 0.5 + 0.5) * (b - a) + a;
|
return (sin(counter * speed * PI - HALF_PI) * 0.5 + 0.5) * (b - a) + a;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
namespace Eule
|
namespace Leonetienne::Eule
|
||||||
{
|
{
|
||||||
/** Math utility class containing basic functions.
|
/** Math utility class containing basic functions.
|
||||||
*/
|
*/
|
||||||
|
@ -7,36 +7,32 @@
|
|||||||
#include <immintrin.h>
|
#include <immintrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace Eule;
|
namespace Leonetienne::Eule {
|
||||||
|
|
||||||
Matrix4x4::Matrix4x4()
|
Matrix4x4::Matrix4x4() {
|
||||||
{
|
|
||||||
// Create identity matrix
|
// Create identity matrix
|
||||||
for (std::size_t i = 0; i < 4; i++)
|
for (std::size_t i = 0; i < 4; i++)
|
||||||
for (std::size_t j = 0; j < 4; j++)
|
for (std::size_t j = 0; j < 4; j++)
|
||||||
v[i][j] = double(i == j);
|
v[i][j] = double(i == j);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4::Matrix4x4(const Matrix4x4& other)
|
Matrix4x4::Matrix4x4(const Matrix4x4 &other) {
|
||||||
{
|
|
||||||
v = other.v;
|
v = other.v;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4::Matrix4x4(Matrix4x4&& other) noexcept
|
Matrix4x4::Matrix4x4(Matrix4x4 &&other) noexcept {
|
||||||
{
|
|
||||||
v = std::move(other.v);
|
v = std::move(other.v);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 Matrix4x4::operator*(const Matrix4x4& other) const
|
Matrix4x4 Matrix4x4::operator*(const Matrix4x4 &other) const {
|
||||||
{
|
|
||||||
Matrix4x4 newMatrix;
|
Matrix4x4 newMatrix;
|
||||||
newMatrix.p = 1;
|
newMatrix.p = 1;
|
||||||
|
|
||||||
#ifndef _EULE_NO_INTRINSICS_
|
#ifndef _EULE_NO_INTRINSICS_
|
||||||
|
|
||||||
|
|
||||||
/* <= Matrix3x3 multiplication => */
|
/* <= Matrix3x3 multiplication => */
|
||||||
@ -117,7 +113,7 @@ Matrix4x4 Matrix4x4::operator*(const Matrix4x4& other) const
|
|||||||
newMatrix.h = sum[1];
|
newMatrix.h = sum[1];
|
||||||
newMatrix.l = sum[2];
|
newMatrix.l = sum[2];
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
||||||
// Rotation, Scaling
|
// Rotation, Scaling
|
||||||
@ -139,33 +135,29 @@ Matrix4x4 Matrix4x4::operator*(const Matrix4x4& other) const
|
|||||||
newMatrix[1][3] = v[1][3] + other[1][3];
|
newMatrix[1][3] = v[1][3] + other[1][3];
|
||||||
newMatrix[2][3] = v[2][3] + other[2][3];
|
newMatrix[2][3] = v[2][3] + other[2][3];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return newMatrix;
|
return newMatrix;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix4x4::operator*=(const Matrix4x4& other)
|
void Matrix4x4::operator*=(const Matrix4x4 &other) {
|
||||||
{
|
|
||||||
*this = *this * other;
|
*this = *this * other;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 Matrix4x4::operator/(const Matrix4x4& other) const
|
Matrix4x4 Matrix4x4::operator/(const Matrix4x4 &other) const {
|
||||||
{
|
|
||||||
return *this * other.Inverse3x3();
|
return *this * other.Inverse3x3();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix4x4::operator/=(const Matrix4x4& other)
|
void Matrix4x4::operator/=(const Matrix4x4 &other) {
|
||||||
{
|
|
||||||
*this = *this * other.Inverse3x3();
|
*this = *this * other.Inverse3x3();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 Matrix4x4::operator*(const double scalar) const
|
Matrix4x4 Matrix4x4::operator*(const double scalar) const {
|
||||||
{
|
|
||||||
Matrix4x4 m;
|
Matrix4x4 m;
|
||||||
|
|
||||||
#ifndef _EULE_NO_INTRINSICS_
|
#ifndef _EULE_NO_INTRINSICS_
|
||||||
|
|
||||||
// Load matrix rows
|
// Load matrix rows
|
||||||
__m256d __row0 = _mm256_set_pd(v[0][3], v[0][2], v[0][1], v[0][0]);
|
__m256d __row0 = _mm256_set_pd(v[0][3], v[0][2], v[0][1], v[0][0]);
|
||||||
@ -188,41 +180,37 @@ Matrix4x4 Matrix4x4::operator*(const double scalar) const
|
|||||||
_mm256_storeu_pd(m.v[2].data(), __sr2);
|
_mm256_storeu_pd(m.v[2].data(), __sr2);
|
||||||
_mm256_storeu_pd(m.v[3].data(), __sr3);
|
_mm256_storeu_pd(m.v[3].data(), __sr3);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
for (std::size_t x = 0; x < 4; x++)
|
for (std::size_t x = 0; x < 4; x++)
|
||||||
for (std::size_t y = 0; y < 4; y++)
|
for (std::size_t y = 0; y < 4; y++)
|
||||||
m[x][y] = v[x][y] * scalar;
|
m[x][y] = v[x][y] * scalar;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix4x4::operator*=(const double scalar)
|
void Matrix4x4::operator*=(const double scalar) {
|
||||||
{
|
|
||||||
*this = *this * scalar;
|
*this = *this * scalar;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 Matrix4x4::operator/(const double denominator) const
|
Matrix4x4 Matrix4x4::operator/(const double denominator) const {
|
||||||
{
|
|
||||||
const double precomputeDivision = 1.0 / denominator;
|
const double precomputeDivision = 1.0 / denominator;
|
||||||
|
|
||||||
return *this * precomputeDivision;
|
return *this * precomputeDivision;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix4x4::operator/=(const double denominator)
|
void Matrix4x4::operator/=(const double denominator) {
|
||||||
{
|
|
||||||
*this = *this / denominator;
|
*this = *this / denominator;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 Matrix4x4::operator+(const Matrix4x4& other) const
|
Matrix4x4 Matrix4x4::operator+(const Matrix4x4 &other) const {
|
||||||
{
|
|
||||||
Matrix4x4 m;
|
Matrix4x4 m;
|
||||||
|
|
||||||
#ifndef _EULE_NO_INTRINSICS_
|
#ifndef _EULE_NO_INTRINSICS_
|
||||||
|
|
||||||
// Load matrix rows
|
// Load matrix rows
|
||||||
__m256d __row0a = _mm256_set_pd(v[0][3], v[0][2], v[0][1], v[0][0]);
|
__m256d __row0a = _mm256_set_pd(v[0][3], v[0][2], v[0][1], v[0][0]);
|
||||||
@ -247,20 +235,19 @@ Matrix4x4 Matrix4x4::operator+(const Matrix4x4& other) const
|
|||||||
_mm256_storeu_pd(m.v[2].data(), __sr2);
|
_mm256_storeu_pd(m.v[2].data(), __sr2);
|
||||||
_mm256_storeu_pd(m.v[3].data(), __sr3);
|
_mm256_storeu_pd(m.v[3].data(), __sr3);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
for (std::size_t x = 0; x < 4; x++)
|
for (std::size_t x = 0; x < 4; x++)
|
||||||
for (std::size_t y = 0; y < 4; y++)
|
for (std::size_t y = 0; y < 4; y++)
|
||||||
m[x][y] = v[x][y] + other[x][y];
|
m[x][y] = v[x][y] + other[x][y];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix4x4::operator+=(const Matrix4x4& other)
|
void Matrix4x4::operator+=(const Matrix4x4 &other) {
|
||||||
{
|
#ifndef _EULE_NO_INTRINSICS_
|
||||||
#ifndef _EULE_NO_INTRINSICS_
|
|
||||||
// Doing it again is a tad directer, and thus faster. We avoid an intermittent Matrix4x4 instance
|
// Doing it again is a tad directer, and thus faster. We avoid an intermittent Matrix4x4 instance
|
||||||
|
|
||||||
// Load matrix rows
|
// Load matrix rows
|
||||||
@ -286,20 +273,19 @@ void Matrix4x4::operator+=(const Matrix4x4& other)
|
|||||||
_mm256_storeu_pd(v[2].data(), __sr2);
|
_mm256_storeu_pd(v[2].data(), __sr2);
|
||||||
_mm256_storeu_pd(v[3].data(), __sr3);
|
_mm256_storeu_pd(v[3].data(), __sr3);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
*this = *this + other;
|
*this = *this + other;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 Matrix4x4::operator-(const Matrix4x4& other) const
|
Matrix4x4 Matrix4x4::operator-(const Matrix4x4 &other) const {
|
||||||
{
|
|
||||||
Matrix4x4 m;
|
Matrix4x4 m;
|
||||||
|
|
||||||
#ifndef _EULE_NO_INTRINSICS_
|
#ifndef _EULE_NO_INTRINSICS_
|
||||||
|
|
||||||
// Load matrix rows
|
// Load matrix rows
|
||||||
__m256d __row0a = _mm256_set_pd(v[0][3], v[0][2], v[0][1], v[0][0]);
|
__m256d __row0a = _mm256_set_pd(v[0][3], v[0][2], v[0][1], v[0][0]);
|
||||||
@ -324,20 +310,19 @@ Matrix4x4 Matrix4x4::operator-(const Matrix4x4& other) const
|
|||||||
_mm256_storeu_pd(m.v[2].data(), __sr2);
|
_mm256_storeu_pd(m.v[2].data(), __sr2);
|
||||||
_mm256_storeu_pd(m.v[3].data(), __sr3);
|
_mm256_storeu_pd(m.v[3].data(), __sr3);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
for (std::size_t x = 0; x < 4; x++)
|
for (std::size_t x = 0; x < 4; x++)
|
||||||
for (std::size_t y = 0; y < 4; y++)
|
for (std::size_t y = 0; y < 4; y++)
|
||||||
m[x][y] = v[x][y] - other[x][y];
|
m[x][y] = v[x][y] - other[x][y];
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix4x4::operator-=(const Matrix4x4& other)
|
void Matrix4x4::operator-=(const Matrix4x4 &other) {
|
||||||
{
|
#ifndef _EULE_NO_INTRINSICS_
|
||||||
#ifndef _EULE_NO_INTRINSICS_
|
|
||||||
// Doing it again is a tad directer, and thus faster. We avoid an intermittent Matrix4x4 instance
|
// Doing it again is a tad directer, and thus faster. We avoid an intermittent Matrix4x4 instance
|
||||||
|
|
||||||
// Load matrix rows
|
// Load matrix rows
|
||||||
@ -363,81 +348,69 @@ void Matrix4x4::operator-=(const Matrix4x4& other)
|
|||||||
_mm256_storeu_pd(v[2].data(), __sr2);
|
_mm256_storeu_pd(v[2].data(), __sr2);
|
||||||
_mm256_storeu_pd(v[3].data(), __sr3);
|
_mm256_storeu_pd(v[3].data(), __sr3);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
* this = *this - other;
|
*this = *this - other;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::array<double, 4>& Matrix4x4::operator[](std::size_t y)
|
std::array<double, 4> &Matrix4x4::operator[](std::size_t y) {
|
||||||
{
|
|
||||||
return v[y];
|
return v[y];
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::array<double, 4>& Matrix4x4::operator[](std::size_t y) const
|
const std::array<double, 4> &Matrix4x4::operator[](std::size_t y) const {
|
||||||
{
|
|
||||||
return v[y];
|
return v[y];
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix4x4::operator=(const Matrix4x4& other)
|
void Matrix4x4::operator=(const Matrix4x4 &other) {
|
||||||
{
|
|
||||||
v = other.v;
|
v = other.v;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix4x4::operator=(Matrix4x4&& other) noexcept
|
void Matrix4x4::operator=(Matrix4x4 &&other) noexcept {
|
||||||
{
|
|
||||||
v = std::move(other.v);
|
v = std::move(other.v);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Matrix4x4::operator==(const Matrix4x4& other)
|
bool Matrix4x4::operator==(const Matrix4x4 &other) {
|
||||||
{
|
|
||||||
return v == other.v;
|
return v == other.v;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Matrix4x4::operator!=(const Matrix4x4& other)
|
bool Matrix4x4::operator!=(const Matrix4x4 &other) {
|
||||||
{
|
|
||||||
return !operator==(other);
|
return !operator==(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Matrix4x4::operator==(const Matrix4x4& other) const
|
bool Matrix4x4::operator==(const Matrix4x4 &other) const {
|
||||||
{
|
|
||||||
return v == other.v;
|
return v == other.v;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Matrix4x4::operator!=(const Matrix4x4& other) const
|
bool Matrix4x4::operator!=(const Matrix4x4 &other) const {
|
||||||
{
|
|
||||||
return !operator==(other);
|
return !operator==(other);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Vector3d Matrix4x4::GetTranslationComponent() const
|
const Vector3d Matrix4x4::GetTranslationComponent() const {
|
||||||
{
|
|
||||||
return Vector3d(d, h, l);
|
return Vector3d(d, h, l);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Matrix4x4::SetTranslationComponent(const Vector3d& trans)
|
void Matrix4x4::SetTranslationComponent(const Vector3d &trans) {
|
||||||
{
|
|
||||||
d = trans.x;
|
d = trans.x;
|
||||||
h = trans.y;
|
h = trans.y;
|
||||||
l = trans.z;
|
l = trans.z;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 Matrix4x4::DropTranslationComponents() const
|
Matrix4x4 Matrix4x4::DropTranslationComponents() const {
|
||||||
{
|
|
||||||
Matrix4x4 m(*this);
|
Matrix4x4 m(*this);
|
||||||
m.d = 0;
|
m.d = 0;
|
||||||
m.h = 0;
|
m.h = 0;
|
||||||
m.l = 0;
|
m.l = 0;
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 Matrix4x4::Transpose3x3() const
|
Matrix4x4 Matrix4x4::Transpose3x3() const {
|
||||||
{
|
|
||||||
Matrix4x4 trans(*this); // Keep other cells
|
Matrix4x4 trans(*this); // Keep other cells
|
||||||
|
|
||||||
for (std::size_t i = 0; i < 3; i++)
|
for (std::size_t i = 0; i < 3; i++)
|
||||||
@ -445,10 +418,9 @@ Matrix4x4 Matrix4x4::Transpose3x3() const
|
|||||||
trans[j][i] = v[i][j];
|
trans[j][i] = v[i][j];
|
||||||
|
|
||||||
return trans;
|
return trans;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 Matrix4x4::Transpose4x4() const
|
Matrix4x4 Matrix4x4::Transpose4x4() const {
|
||||||
{
|
|
||||||
Matrix4x4 trans;
|
Matrix4x4 trans;
|
||||||
|
|
||||||
for (std::size_t i = 0; i < 4; i++)
|
for (std::size_t i = 0; i < 4; i++)
|
||||||
@ -456,37 +428,35 @@ Matrix4x4 Matrix4x4::Transpose4x4() const
|
|||||||
trans[j][i] = v[i][j];
|
trans[j][i] = v[i][j];
|
||||||
|
|
||||||
return trans;
|
return trans;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 Matrix4x4::Multiply4x4(const Matrix4x4& o) const
|
Matrix4x4 Matrix4x4::Multiply4x4(const Matrix4x4 &o) const {
|
||||||
{
|
|
||||||
Matrix4x4 m;
|
Matrix4x4 m;
|
||||||
|
|
||||||
m[0][0] = (v[0][0]*o[0][0]) + (v[0][1]*o[1][0]) + (v[0][2]*o[2][0]) + (v[0][3]*o[3][0]);
|
m[0][0] = (v[0][0] * o[0][0]) + (v[0][1] * o[1][0]) + (v[0][2] * o[2][0]) + (v[0][3] * o[3][0]);
|
||||||
m[0][1] = (v[0][0]*o[0][1]) + (v[0][1]*o[1][1]) + (v[0][2]*o[2][1]) + (v[0][3]*o[3][1]);
|
m[0][1] = (v[0][0] * o[0][1]) + (v[0][1] * o[1][1]) + (v[0][2] * o[2][1]) + (v[0][3] * o[3][1]);
|
||||||
m[0][2] = (v[0][0]*o[0][2]) + (v[0][1]*o[1][2]) + (v[0][2]*o[2][2]) + (v[0][3]*o[3][2]);
|
m[0][2] = (v[0][0] * o[0][2]) + (v[0][1] * o[1][2]) + (v[0][2] * o[2][2]) + (v[0][3] * o[3][2]);
|
||||||
m[0][3] = (v[0][0]*o[0][3]) + (v[0][1]*o[1][3]) + (v[0][2]*o[2][3]) + (v[0][3]*o[3][3]);
|
m[0][3] = (v[0][0] * o[0][3]) + (v[0][1] * o[1][3]) + (v[0][2] * o[2][3]) + (v[0][3] * o[3][3]);
|
||||||
|
|
||||||
m[1][0] = (v[1][0]*o[0][0]) + (v[1][1]*o[1][0]) + (v[1][2]*o[2][0]) + (v[1][3]*o[3][0]);
|
m[1][0] = (v[1][0] * o[0][0]) + (v[1][1] * o[1][0]) + (v[1][2] * o[2][0]) + (v[1][3] * o[3][0]);
|
||||||
m[1][1] = (v[1][0]*o[0][1]) + (v[1][1]*o[1][1]) + (v[1][2]*o[2][1]) + (v[1][3]*o[3][1]);
|
m[1][1] = (v[1][0] * o[0][1]) + (v[1][1] * o[1][1]) + (v[1][2] * o[2][1]) + (v[1][3] * o[3][1]);
|
||||||
m[1][2] = (v[1][0]*o[0][2]) + (v[1][1]*o[1][2]) + (v[1][2]*o[2][2]) + (v[1][3]*o[3][2]);
|
m[1][2] = (v[1][0] * o[0][2]) + (v[1][1] * o[1][2]) + (v[1][2] * o[2][2]) + (v[1][3] * o[3][2]);
|
||||||
m[1][3] = (v[1][0]*o[0][3]) + (v[1][1]*o[1][3]) + (v[1][2]*o[2][3]) + (v[1][3]*o[3][3]);
|
m[1][3] = (v[1][0] * o[0][3]) + (v[1][1] * o[1][3]) + (v[1][2] * o[2][3]) + (v[1][3] * o[3][3]);
|
||||||
|
|
||||||
m[2][0] = (v[2][0]*o[0][0]) + (v[2][1]*o[1][0]) + (v[2][2]*o[2][0]) + (v[2][3]*o[3][0]);
|
m[2][0] = (v[2][0] * o[0][0]) + (v[2][1] * o[1][0]) + (v[2][2] * o[2][0]) + (v[2][3] * o[3][0]);
|
||||||
m[2][1] = (v[2][0]*o[0][1]) + (v[2][1]*o[1][1]) + (v[2][2]*o[2][1]) + (v[2][3]*o[3][1]);
|
m[2][1] = (v[2][0] * o[0][1]) + (v[2][1] * o[1][1]) + (v[2][2] * o[2][1]) + (v[2][3] * o[3][1]);
|
||||||
m[2][2] = (v[2][0]*o[0][2]) + (v[2][1]*o[1][2]) + (v[2][2]*o[2][2]) + (v[2][3]*o[3][2]);
|
m[2][2] = (v[2][0] * o[0][2]) + (v[2][1] * o[1][2]) + (v[2][2] * o[2][2]) + (v[2][3] * o[3][2]);
|
||||||
m[2][3] = (v[2][0]*o[0][3]) + (v[2][1]*o[1][3]) + (v[2][2]*o[2][3]) + (v[2][3]*o[3][3]);
|
m[2][3] = (v[2][0] * o[0][3]) + (v[2][1] * o[1][3]) + (v[2][2] * o[2][3]) + (v[2][3] * o[3][3]);
|
||||||
|
|
||||||
m[3][0] = (v[3][0]*o[0][0]) + (v[3][1]*o[1][0]) + (v[3][2]*o[2][0]) + (v[3][3]*o[3][0]);
|
m[3][0] = (v[3][0] * o[0][0]) + (v[3][1] * o[1][0]) + (v[3][2] * o[2][0]) + (v[3][3] * o[3][0]);
|
||||||
m[3][1] = (v[3][0]*o[0][1]) + (v[3][1]*o[1][1]) + (v[3][2]*o[2][1]) + (v[3][3]*o[3][1]);
|
m[3][1] = (v[3][0] * o[0][1]) + (v[3][1] * o[1][1]) + (v[3][2] * o[2][1]) + (v[3][3] * o[3][1]);
|
||||||
m[3][2] = (v[3][0]*o[0][2]) + (v[3][1]*o[1][2]) + (v[3][2]*o[2][2]) + (v[3][3]*o[3][2]);
|
m[3][2] = (v[3][0] * o[0][2]) + (v[3][1] * o[1][2]) + (v[3][2] * o[2][2]) + (v[3][3] * o[3][2]);
|
||||||
m[3][3] = (v[3][0]*o[0][3]) + (v[3][1]*o[1][3]) + (v[3][2]*o[2][3]) + (v[3][3]*o[3][3]);
|
m[3][3] = (v[3][0] * o[0][3]) + (v[3][1] * o[1][3]) + (v[3][2] * o[2][3]) + (v[3][3] * o[3][3]);
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 Matrix4x4::GetCofactors(std::size_t p, std::size_t q, std::size_t n) const
|
Matrix4x4 Matrix4x4::GetCofactors(std::size_t p, std::size_t q, std::size_t n) const {
|
||||||
{
|
|
||||||
if (n > 4)
|
if (n > 4)
|
||||||
throw std::runtime_error("Dimension out of range! 0 <= n <= 4");
|
throw std::runtime_error("Dimension out of range! 0 <= n <= 4");
|
||||||
|
|
||||||
@ -496,30 +466,26 @@ Matrix4x4 Matrix4x4::GetCofactors(std::size_t p, std::size_t q, std::size_t n) c
|
|||||||
std::size_t j = 0;
|
std::size_t j = 0;
|
||||||
|
|
||||||
for (std::size_t y = 0; y < n; y++)
|
for (std::size_t y = 0; y < n; y++)
|
||||||
for (std::size_t x = 0; x < n; x++)
|
for (std::size_t x = 0; x < n; x++) {
|
||||||
{
|
if ((y != p) && (x != q)) {
|
||||||
if ((y != p) && (x != q))
|
|
||||||
{
|
|
||||||
cofs[i][j] = v[y][x];
|
cofs[i][j] = v[y][x];
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (j == n - 1)
|
if (j == n - 1) {
|
||||||
{
|
|
||||||
j = 0;
|
j = 0;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return cofs;
|
return cofs;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* BEGIN_REF
|
* BEGIN_REF
|
||||||
* https://www.geeksforgeeks.org/adjoint-inverse-matrix/
|
* https://www.geeksforgeeks.org/adjoint-inverse-matrix/
|
||||||
*/
|
*/
|
||||||
double Matrix4x4::Determinant(std::size_t n) const
|
double Matrix4x4::Determinant(std::size_t n) const {
|
||||||
{
|
|
||||||
if (n > 4)
|
if (n > 4)
|
||||||
throw std::runtime_error("Dimension out of range! 0 <= n <= 4");
|
throw std::runtime_error("Dimension out of range! 0 <= n <= 4");
|
||||||
|
|
||||||
@ -529,8 +495,7 @@ double Matrix4x4::Determinant(std::size_t n) const
|
|||||||
if (n == 1)
|
if (n == 1)
|
||||||
return v[0][0];
|
return v[0][0];
|
||||||
|
|
||||||
for (std::size_t x = 0; x < n; x++)
|
for (std::size_t x = 0; x < n; x++) {
|
||||||
{
|
|
||||||
Matrix4x4 cofs = GetCofactors(0, x, n);
|
Matrix4x4 cofs = GetCofactors(0, x, n);
|
||||||
|
|
||||||
d += sign * v[0][x] * cofs.Determinant(n - 1);
|
d += sign * v[0][x] * cofs.Determinant(n - 1);
|
||||||
@ -538,10 +503,9 @@ double Matrix4x4::Determinant(std::size_t n) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return d;
|
return d;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 Matrix4x4::Adjoint(std::size_t n) const
|
Matrix4x4 Matrix4x4::Adjoint(std::size_t n) const {
|
||||||
{
|
|
||||||
if (n > 4)
|
if (n > 4)
|
||||||
throw std::runtime_error("Dimension out of range! 0 <= n <= 4");
|
throw std::runtime_error("Dimension out of range! 0 <= n <= 4");
|
||||||
|
|
||||||
@ -549,8 +513,7 @@ Matrix4x4 Matrix4x4::Adjoint(std::size_t n) const
|
|||||||
double sign = 1;
|
double sign = 1;
|
||||||
|
|
||||||
for (std::size_t i = 0; i < n; i++)
|
for (std::size_t i = 0; i < n; i++)
|
||||||
for (std::size_t j = 0; j < n; j++)
|
for (std::size_t j = 0; j < n; j++) {
|
||||||
{
|
|
||||||
Matrix4x4 cofs = GetCofactors(i, j, n);
|
Matrix4x4 cofs = GetCofactors(i, j, n);
|
||||||
|
|
||||||
// sign of adj[j][i] positive if sum of row
|
// sign of adj[j][i] positive if sum of row
|
||||||
@ -563,10 +526,9 @@ Matrix4x4 Matrix4x4::Adjoint(std::size_t n) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
return adj;
|
return adj;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 Matrix4x4::Inverse3x3() const
|
Matrix4x4 Matrix4x4::Inverse3x3() const {
|
||||||
{
|
|
||||||
Matrix4x4 inv;
|
Matrix4x4 inv;
|
||||||
|
|
||||||
double det = Determinant(3);
|
double det = Determinant(3);
|
||||||
@ -582,10 +544,9 @@ Matrix4x4 Matrix4x4::Inverse3x3() const
|
|||||||
inv.SetTranslationComponent(-GetTranslationComponent());
|
inv.SetTranslationComponent(-GetTranslationComponent());
|
||||||
|
|
||||||
return inv;
|
return inv;
|
||||||
}
|
}
|
||||||
|
|
||||||
Matrix4x4 Matrix4x4::Inverse4x4() const
|
Matrix4x4 Matrix4x4::Inverse4x4() const {
|
||||||
{
|
|
||||||
Matrix4x4 inv;
|
Matrix4x4 inv;
|
||||||
|
|
||||||
double det = Determinant(4);
|
double det = Determinant(4);
|
||||||
@ -599,40 +560,34 @@ Matrix4x4 Matrix4x4::Inverse4x4() const
|
|||||||
inv[i][j] = adj[i][j] / det;
|
inv[i][j] = adj[i][j] / det;
|
||||||
|
|
||||||
return inv;
|
return inv;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* END REF
|
* END REF
|
||||||
*/
|
*/
|
||||||
|
|
||||||
bool Matrix4x4::IsInversible3x3() const
|
bool Matrix4x4::IsInversible3x3() const {
|
||||||
{
|
|
||||||
return (Determinant(3) != 0);
|
return (Determinant(3) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Matrix4x4::IsInversible4x4() const
|
bool Matrix4x4::IsInversible4x4() const {
|
||||||
{
|
|
||||||
return (Determinant(4) != 0);
|
return (Determinant(4) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Matrix4x4::Similar(const Matrix4x4& other, double epsilon) const
|
bool Matrix4x4::Similar(const Matrix4x4 &other, double epsilon) const {
|
||||||
{
|
|
||||||
for (std::size_t i = 0; i < 4; i++)
|
for (std::size_t i = 0; i < 4; i++)
|
||||||
for (std::size_t j = 0; j < 4; j++)
|
for (std::size_t j = 0; j < 4; j++)
|
||||||
if (!Math::Similar(v[i][j], other[i][j], epsilon))
|
if (!Math::Similar(v[i][j], other[i][j], epsilon))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace Eule
|
namespace Eule {
|
||||||
{
|
std::ostream &operator<<(std::ostream &os, const Matrix4x4 &m) {
|
||||||
std::ostream& operator<< (std::ostream& os, const Matrix4x4& m)
|
|
||||||
{
|
|
||||||
os << std::endl;
|
os << std::endl;
|
||||||
|
|
||||||
for (std::size_t y = 0; y < 4; y++)
|
for (std::size_t y = 0; y < 4; y++) {
|
||||||
{
|
|
||||||
for (std::size_t x = 0; x < 4; x++)
|
for (std::size_t x = 0; x < 4; x++)
|
||||||
os << " | " << m[y][x];
|
os << " | " << m[y][x];
|
||||||
|
|
||||||
@ -642,12 +597,10 @@ namespace Eule
|
|||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::wostream& operator<< (std::wostream& os, const Matrix4x4& m)
|
std::wostream &operator<<(std::wostream &os, const Matrix4x4 &m) {
|
||||||
{
|
|
||||||
os << std::endl;
|
os << std::endl;
|
||||||
|
|
||||||
for (std::size_t y = 0; y < 4; y++)
|
for (std::size_t y = 0; y < 4; y++) {
|
||||||
{
|
|
||||||
for (std::size_t x = 0; x < 4; x++)
|
for (std::size_t x = 0; x < 4; x++)
|
||||||
os << L" | " << m[y][x];
|
os << L" | " << m[y][x];
|
||||||
|
|
||||||
@ -656,4 +609,5 @@ namespace Eule
|
|||||||
|
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
namespace Eule
|
namespace Leonetienne::Eule
|
||||||
{
|
{
|
||||||
template <class T>
|
template <class T>
|
||||||
class Vector3;
|
class Vector3;
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include "gcccompat.h"
|
#include "gcccompat.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
namespace Eule {
|
namespace Leonetienne::Eule {
|
||||||
|
|
||||||
Quaternion::Quaternion()
|
Quaternion::Quaternion()
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "Matrix4x4.h"
|
#include "Matrix4x4.h"
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
namespace Eule
|
namespace Leonetienne::Eule
|
||||||
{
|
{
|
||||||
/** 3D rotation representation
|
/** 3D rotation representation
|
||||||
*/
|
*/
|
||||||
|
@ -2,13 +2,11 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
using namespace Eule;
|
namespace Leonetienne::Eule {
|
||||||
|
|
||||||
// Checks if the random number generator is initialized. Does nothing if it is, initializes if it isn't.
|
// Checks if the random number generator is initialized. Does nothing if it is, initializes if it isn't.
|
||||||
#define MAKE_SURE_RNG_IS_INITIALIZED if (!isRngInitialized) InitRng();
|
#define MAKE_SURE_RNG_IS_INITIALIZED if (!isRngInitialized) InitRng();
|
||||||
|
|
||||||
void Random::InitRng()
|
void Random::InitRng() {
|
||||||
{
|
|
||||||
// Create truly random source (from hardware events)
|
// Create truly random source (from hardware events)
|
||||||
std::random_device randomSource;
|
std::random_device randomSource;
|
||||||
|
|
||||||
@ -23,54 +21,49 @@ void Random::InitRng()
|
|||||||
isRngInitialized = true;
|
isRngInitialized = true;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Will return a random double between 0 and 1
|
// Will return a random double between 0 and 1
|
||||||
double Random::RandomFloat()
|
double Random::RandomFloat() {
|
||||||
{
|
|
||||||
MAKE_SURE_RNG_IS_INITIALIZED;
|
MAKE_SURE_RNG_IS_INITIALIZED;
|
||||||
|
|
||||||
return (rng() % 694206942069ll) / 694206942069.0;
|
return (rng() % 694206942069ll) / 694206942069.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Will return a random unsigned integer.
|
// Will return a random unsigned integer.
|
||||||
unsigned int Random::RandomUint()
|
unsigned int Random::RandomUint() {
|
||||||
{
|
|
||||||
MAKE_SURE_RNG_IS_INITIALIZED;
|
MAKE_SURE_RNG_IS_INITIALIZED;
|
||||||
|
|
||||||
return rng();
|
return rng();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Will return a random integer
|
// Will return a random integer
|
||||||
unsigned int Random::RandomInt()
|
unsigned int Random::RandomInt() {
|
||||||
{
|
|
||||||
MAKE_SURE_RNG_IS_INITIALIZED;
|
MAKE_SURE_RNG_IS_INITIALIZED;
|
||||||
|
|
||||||
// Since this is supposed to return a random value anyways,
|
// Since this is supposed to return a random value anyways,
|
||||||
// we can let the random uint overflow without any problems.
|
// we can let the random uint overflow without any problems.
|
||||||
return (int)rng();
|
return (int) rng();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Will return a random double within a range
|
// Will return a random double within a range
|
||||||
// These bounds are INCLUSIVE!
|
// These bounds are INCLUSIVE!
|
||||||
double Random::RandomRange(double min, double max)
|
double Random::RandomRange(double min, double max) {
|
||||||
{
|
|
||||||
return (RandomFloat() * (max - min)) + min;
|
return (RandomFloat() * (max - min)) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Will return a random integer within a range. This is faster than '(int)RandomRange(x,y)'
|
// Will return a random integer within a range. This is faster than '(int)RandomRange(x,y)'
|
||||||
// These bounds are INCLUSIVE!
|
// These bounds are INCLUSIVE!
|
||||||
int Random::RandomIntRange(int min, int max)
|
int Random::RandomIntRange(int min, int max) {
|
||||||
{
|
|
||||||
MAKE_SURE_RNG_IS_INITIALIZED;
|
MAKE_SURE_RNG_IS_INITIALIZED;
|
||||||
|
|
||||||
return (rng() % (max + 1 - min)) + min;
|
return (rng() % (max + 1 - min)) + min;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Random::RandomChance(const double chance)
|
bool Random::RandomChance(const double chance) {
|
||||||
{
|
|
||||||
return RandomFloat() <= chance;
|
return RandomFloat() <= chance;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::mt19937 Random::rng;
|
std::mt19937 Random::rng;
|
||||||
bool Random::isRngInitialized = false;
|
bool Random::isRngInitialized = false;
|
||||||
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <random>
|
#include <random>
|
||||||
|
|
||||||
namespace Eule
|
namespace Leonetienne::Eule
|
||||||
{
|
{
|
||||||
/** Extensive random number generator
|
/** Extensive random number generator
|
||||||
*/
|
*/
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "../Eule/Vector2.h"
|
#include "../Eule/Vector2.h"
|
||||||
|
|
||||||
namespace Eule
|
namespace Leonetienne::Eule
|
||||||
{
|
{
|
||||||
/** Trivial data structure representing a rectangle
|
/** Trivial data structure representing a rectangle
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include "TrapazoidalPrismCollider.h"
|
#include "TrapazoidalPrismCollider.h"
|
||||||
|
|
||||||
using namespace Eule;
|
using namespace Leonetienne::Eule;
|
||||||
|
|
||||||
TrapazoidalPrismCollider::TrapazoidalPrismCollider()
|
TrapazoidalPrismCollider::TrapazoidalPrismCollider()
|
||||||
{
|
{
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
#include "Collider.h"
|
#include "Collider.h"
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
namespace Eule
|
namespace Leonetienne::Eule
|
||||||
{
|
{
|
||||||
/** A collider describing a trapazoidal prism.
|
/** A collider describing a trapazoidal prism.
|
||||||
* A trapazoidal prism is basically a box, but each vertex can be manipulated individually, altering
|
* A trapazoidal prism is basically a box, but each vertex can be manipulated individually, altering
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
The T=int instantiation only exists to store a value-pair of two ints. Not so-much as a vector in terms of vector calculus.
|
The T=int instantiation only exists to store a value-pair of two ints. Not so-much as a vector in terms of vector calculus.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Eule {
|
namespace Leonetienne::Eule {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Vector2<T>::operator Vector3<T>() const
|
Vector2<T>::operator Vector3<T>() const
|
||||||
@ -322,8 +322,8 @@ namespace Eule {
|
|||||||
bool Vector2<T>::Similar(const Vector2<T>& other, double epsilon) const
|
bool Vector2<T>::Similar(const Vector2<T>& other, double epsilon) const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(::Eule::Math::Similar(x, other.x, epsilon)) &&
|
(::Leonetienne::Eule::Math::Similar(x, other.x, epsilon)) &&
|
||||||
(::Eule::Math::Similar(y, other.y, epsilon))
|
(::Leonetienne::Eule::Math::Similar(y, other.y, epsilon))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
|
||||||
namespace Eule {
|
namespace Leonetienne::Eule {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class Vector3;
|
class Vector3;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
The T=int instantiation only exists to store a value-pair of two ints. Not so-much as a vector in terms of vector calculus.
|
The T=int instantiation only exists to store a value-pair of two ints. Not so-much as a vector in terms of vector calculus.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Eule {
|
namespace Leonetienne::Eule {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Vector3<T>::operator Vector2<T>() const
|
Vector3<T>::operator Vector2<T>() const
|
||||||
{
|
{
|
||||||
@ -235,9 +235,9 @@ namespace Eule {
|
|||||||
bool Vector3<T>::Similar(const Vector3<T>& other, double epsilon) const
|
bool Vector3<T>::Similar(const Vector3<T>& other, double epsilon) const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(::Eule::Math::Similar(x, other.x, epsilon)) &&
|
(::Leonetienne::Eule::Math::Similar(x, other.x, epsilon)) &&
|
||||||
(::Eule::Math::Similar(y, other.y, epsilon)) &&
|
(::Leonetienne::Eule::Math::Similar(y, other.y, epsilon)) &&
|
||||||
(::Eule::Math::Similar(z, other.z, epsilon))
|
(::Leonetienne::Eule::Math::Similar(z, other.z, epsilon))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "Matrix4x4.h"
|
#include "Matrix4x4.h"
|
||||||
|
|
||||||
namespace Eule {
|
namespace Leonetienne::Eule {
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class Vector2;
|
class Vector2;
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
The T=int instantiation only exists to store a value-pair of two ints. Not so-much as a vector in terms of vector calculus.
|
The T=int instantiation only exists to store a value-pair of two ints. Not so-much as a vector in terms of vector calculus.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
namespace Eule {
|
namespace Leonetienne::Eule {
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
Vector4<T>::operator Vector2<T>() const
|
Vector4<T>::operator Vector2<T>() const
|
||||||
@ -183,10 +183,10 @@ namespace Eule {
|
|||||||
bool Vector4<T>::Similar(const Vector4<T>& other, double epsilon) const
|
bool Vector4<T>::Similar(const Vector4<T>& other, double epsilon) const
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(::Eule::Math::Similar(x, other.x, epsilon)) &&
|
(::Leonetienne::Eule::Math::Similar(x, other.x, epsilon)) &&
|
||||||
(::Eule::Math::Similar(y, other.y, epsilon)) &&
|
(::Leonetienne::Eule::Math::Similar(y, other.y, epsilon)) &&
|
||||||
(::Eule::Math::Similar(z, other.z, epsilon)) &&
|
(::Leonetienne::Eule::Math::Similar(z, other.z, epsilon)) &&
|
||||||
(::Eule::Math::Similar(w, other.w, epsilon))
|
(::Leonetienne::Eule::Math::Similar(w, other.w, epsilon))
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include "Matrix4x4.h"
|
#include "Matrix4x4.h"
|
||||||
|
|
||||||
namespace Eule
|
namespace Leonetienne::Eule
|
||||||
{
|
{
|
||||||
template <typename T> class Vector2;
|
template <typename T> class Vector2;
|
||||||
template <typename T> class Vector3;
|
template <typename T> class Vector3;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user