From 9a5f12e5050c39588426210f8f9c62ddaad656d6 Mon Sep 17 00:00:00 2001 From: josh Date: Fri, 2 Feb 2024 13:53:23 -0500 Subject: [PATCH] Implement J3ML Namespace --- include/J3ML/Geometry.h | 6 +- include/J3ML/Geometry/AABB.h | 2 +- include/J3ML/Geometry/AABB2D.h | 2 +- include/J3ML/Geometry/Capsule.h | 2 +- include/J3ML/Geometry/Frustum.h | 4 +- include/J3ML/Geometry/LineSegment.h | 2 +- include/J3ML/Geometry/OBB.h | 2 +- include/J3ML/Geometry/Plane.h | 19 +++-- include/J3ML/Geometry/Polygon.h | 2 +- include/J3ML/Geometry/Polyhedron.h | 2 +- include/J3ML/Geometry/QuadTree.h | 2 +- include/J3ML/Geometry/Ray.h | 2 +- include/J3ML/Geometry/Sphere.h | 2 +- include/J3ML/Geometry/Triangle.h | 2 +- include/J3ML/Geometry/Triangle2D.h | 14 ++-- include/J3ML/Geometry/TriangleMesh.h | 2 +- include/J3ML/LinearAlgebra.h | 4 +- include/J3ML/LinearAlgebra/Angle2D.h | 2 +- include/J3ML/LinearAlgebra/AxisAngle.h | 2 +- include/J3ML/LinearAlgebra/CoordinateFrame.h | 2 +- include/J3ML/LinearAlgebra/EulerAngle.h | 2 +- include/J3ML/LinearAlgebra/Matrix2x2.h | 2 +- include/J3ML/LinearAlgebra/Matrix3x3.h | 2 +- include/J3ML/LinearAlgebra/Matrix4x4.h | 2 +- include/J3ML/LinearAlgebra/Quaternion.h | 2 +- include/J3ML/LinearAlgebra/Transform2D.h | 2 +- include/J3ML/LinearAlgebra/Vector2.h | 2 +- include/J3ML/LinearAlgebra/Vector3.h | 2 +- include/J3ML/LinearAlgebra/Vector4.h | 2 +- src/J3ML/Geometry/Capsule.cpp | 2 +- src/J3ML/Geometry/Frustum.cpp | 2 +- src/J3ML/Geometry/LineSegment.cpp | 2 +- src/J3ML/LinearAlgebra/AxisAngle.cpp | 2 +- src/J3ML/LinearAlgebra/EulerAngle.cpp | 75 ++++++++++---------- src/J3ML/LinearAlgebra/Matrix2x2.cpp | 2 +- src/J3ML/LinearAlgebra/Matrix3x3.cpp | 2 +- src/J3ML/LinearAlgebra/Matrix4x4.cpp | 2 +- src/J3ML/LinearAlgebra/Quaternion.cpp | 2 +- src/J3ML/LinearAlgebra/Transform2D.cpp | 2 +- src/J3ML/LinearAlgebra/Vector2.cpp | 2 +- src/J3ML/LinearAlgebra/Vector3.cpp | 6 +- src/J3ML/LinearAlgebra/Vector4.cpp | 2 +- tests/LinearAlgebra/Vector2Tests.cpp | 2 +- tests/LinearAlgebra/Vector3Tests.cpp | 5 +- tests/LinearAlgebra/Vector4Tests.cpp | 2 +- 45 files changed, 108 insertions(+), 99 deletions(-) diff --git a/include/J3ML/Geometry.h b/include/J3ML/Geometry.h index 24f53ad..7e90840 100644 --- a/include/J3ML/Geometry.h +++ b/include/J3ML/Geometry.h @@ -3,9 +3,9 @@ #pragma once -namespace Geometry { - using Vector2 = LinearAlgebra::Vector2; - using Vector3 = LinearAlgebra::Vector3; +namespace J3ML::Geometry { + using Vector2 = J3ML::LinearAlgebra::Vector2; + using Vector3 = J3ML::LinearAlgebra::Vector3; class LineSegment2D { diff --git a/include/J3ML/Geometry/AABB.h b/include/J3ML/Geometry/AABB.h index ebb7969..ced9fd0 100644 --- a/include/J3ML/Geometry/AABB.h +++ b/include/J3ML/Geometry/AABB.h @@ -22,7 +22,7 @@ -namespace Geometry +namespace J3ML::Geometry { using namespace LinearAlgebra; diff --git a/include/J3ML/Geometry/AABB2D.h b/include/J3ML/Geometry/AABB2D.h index 993ccb6..53c5614 100644 --- a/include/J3ML/Geometry/AABB2D.h +++ b/include/J3ML/Geometry/AABB2D.h @@ -2,7 +2,7 @@ #include -namespace Geometry +namespace J3ML::Geometry { using LinearAlgebra::Vector2; // CaveGame AABB diff --git a/include/J3ML/Geometry/Capsule.h b/include/J3ML/Geometry/Capsule.h index 35770ed..71ca2c5 100644 --- a/include/J3ML/Geometry/Capsule.h +++ b/include/J3ML/Geometry/Capsule.h @@ -3,7 +3,7 @@ #include "LineSegment.h" #include -namespace Geometry +namespace J3ML::Geometry { using namespace LinearAlgebra; class Capsule diff --git a/include/J3ML/Geometry/Frustum.h b/include/J3ML/Geometry/Frustum.h index 14244c6..7819e83 100644 --- a/include/J3ML/Geometry/Frustum.h +++ b/include/J3ML/Geometry/Frustum.h @@ -6,9 +6,11 @@ #include "Plane.h" #include -namespace Geometry +namespace J3ML::Geometry { + using J3ML::LinearAlgebra::CoordinateFrame; + enum class FrustumType { Invalid, diff --git a/include/J3ML/Geometry/LineSegment.h b/include/J3ML/Geometry/LineSegment.h index 4e4d79a..0532cd9 100644 --- a/include/J3ML/Geometry/LineSegment.h +++ b/include/J3ML/Geometry/LineSegment.h @@ -2,7 +2,7 @@ #include -namespace Geometry +namespace J3ML::Geometry { using LinearAlgebra::Vector3; class LineSegment diff --git a/include/J3ML/Geometry/OBB.h b/include/J3ML/Geometry/OBB.h index 1146e0a..55e6493 100644 --- a/include/J3ML/Geometry/OBB.h +++ b/include/J3ML/Geometry/OBB.h @@ -5,7 +5,7 @@ #include #include -namespace Geometry { +namespace J3ML::Geometry { class OBB { public: diff --git a/include/J3ML/Geometry/Plane.h b/include/J3ML/Geometry/Plane.h index 4626b7b..ab7d9ea 100644 --- a/include/J3ML/Geometry/Plane.h +++ b/include/J3ML/Geometry/Plane.h @@ -1,13 +1,18 @@ #pragma once #include -using namespace LinearAlgebra; -class Plane + +namespace J3ML::Geometry { -public: - Vector3 Position; - Vector3 Normal; - float distance = 0.f; + using J3ML::LinearAlgebra::Vector3; -}; \ No newline at end of file + class Plane + { + public: + Vector3 Position; + Vector3 Normal; + float distance = 0.f; + + }; +} \ No newline at end of file diff --git a/include/J3ML/Geometry/Polygon.h b/include/J3ML/Geometry/Polygon.h index 79fb8b1..2513f54 100644 --- a/include/J3ML/Geometry/Polygon.h +++ b/include/J3ML/Geometry/Polygon.h @@ -1,6 +1,6 @@ #pragma once -namespace Geometry { +namespace J3ML::Geometry { class Polygon { }; diff --git a/include/J3ML/Geometry/Polyhedron.h b/include/J3ML/Geometry/Polyhedron.h index 6922624..492b8e6 100644 --- a/include/J3ML/Geometry/Polyhedron.h +++ b/include/J3ML/Geometry/Polyhedron.h @@ -1,6 +1,6 @@ #pragma once -namespace Geometry +namespace J3ML::Geometry { class Polyhedron { diff --git a/include/J3ML/Geometry/QuadTree.h b/include/J3ML/Geometry/QuadTree.h index 2e3803a..7eb9e26 100644 --- a/include/J3ML/Geometry/QuadTree.h +++ b/include/J3ML/Geometry/QuadTree.h @@ -5,7 +5,7 @@ #include #include "AABB2D.h" -namespace Geometry { +namespace J3ML::Geometry { using LinearAlgebra::Vector2; diff --git a/include/J3ML/Geometry/Ray.h b/include/J3ML/Geometry/Ray.h index a5cc415..053a7ed 100644 --- a/include/J3ML/Geometry/Ray.h +++ b/include/J3ML/Geometry/Ray.h @@ -6,7 +6,7 @@ #include -namespace Geometry +namespace J3ML::Geometry { using LinearAlgebra::Vector3; class Ray diff --git a/include/J3ML/Geometry/Sphere.h b/include/J3ML/Geometry/Sphere.h index 9203b5f..386484e 100644 --- a/include/J3ML/Geometry/Sphere.h +++ b/include/J3ML/Geometry/Sphere.h @@ -2,7 +2,7 @@ #include "J3ML/Geometry.h" -namespace Geometry +namespace J3ML::Geometry { class Sphere { diff --git a/include/J3ML/Geometry/Triangle.h b/include/J3ML/Geometry/Triangle.h index f143b0d..f0c9461 100644 --- a/include/J3ML/Geometry/Triangle.h +++ b/include/J3ML/Geometry/Triangle.h @@ -1,6 +1,6 @@ #pragma once -namespace Geometry +namespace J3ML::Geometry { class Triangle { diff --git a/include/J3ML/Geometry/Triangle2D.h b/include/J3ML/Geometry/Triangle2D.h index 188caf2..af804bc 100644 --- a/include/J3ML/Geometry/Triangle2D.h +++ b/include/J3ML/Geometry/Triangle2D.h @@ -1,8 +1,10 @@ -// -// Created by dawsh on 1/25/24. -// +#pragma once -#ifndef J3ML_TRIANGLE2D_H -#define J3ML_TRIANGLE2D_H -#endif //J3ML_TRIANGLE2D_H +namespace J3ML::Geometry +{ + class Shape2D {}; + class Triangle2D { + public: + }; +} \ No newline at end of file diff --git a/include/J3ML/Geometry/TriangleMesh.h b/include/J3ML/Geometry/TriangleMesh.h index dc68b9a..938634e 100644 --- a/include/J3ML/Geometry/TriangleMesh.h +++ b/include/J3ML/Geometry/TriangleMesh.h @@ -1,6 +1,6 @@ #pragma once -namespace Geometry +namespace J3ML::Geometry { class TriangleMesh { diff --git a/include/J3ML/LinearAlgebra.h b/include/J3ML/LinearAlgebra.h index d36c17c..f6acdba 100644 --- a/include/J3ML/LinearAlgebra.h +++ b/include/J3ML/LinearAlgebra.h @@ -6,7 +6,7 @@ #include -namespace Math +namespace J3ML::Math { const float Pi = M_PI; inline float Radians(float degrees) { return degrees * (Pi/180.f); } @@ -29,7 +29,7 @@ namespace Math // Dawsh Linear Algebra Library - Everything you need for 3D math -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { class Vector2; // A type representing a position in a 2-dimensional coordinate space. class Vector3; // A type representing a position in a 3-dimensional coordinate space. class Vector4; // A type representing a position in a 4-dimensional coordinate space. diff --git a/include/J3ML/LinearAlgebra/Angle2D.h b/include/J3ML/LinearAlgebra/Angle2D.h index 1b90d59..31258cf 100644 --- a/include/J3ML/LinearAlgebra/Angle2D.h +++ b/include/J3ML/LinearAlgebra/Angle2D.h @@ -2,7 +2,7 @@ #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { class Angle2D { public: float x; diff --git a/include/J3ML/LinearAlgebra/AxisAngle.h b/include/J3ML/LinearAlgebra/AxisAngle.h index 12cc047..0b4e697 100644 --- a/include/J3ML/LinearAlgebra/AxisAngle.h +++ b/include/J3ML/LinearAlgebra/AxisAngle.h @@ -3,7 +3,7 @@ #include #include -namespace LinearAlgebra +namespace J3ML::LinearAlgebra { /// Transitional datatype, not useful for internal representation of rotation diff --git a/include/J3ML/LinearAlgebra/CoordinateFrame.h b/include/J3ML/LinearAlgebra/CoordinateFrame.h index c2ac41c..f38f255 100644 --- a/include/J3ML/LinearAlgebra/CoordinateFrame.h +++ b/include/J3ML/LinearAlgebra/CoordinateFrame.h @@ -3,7 +3,7 @@ #include #include -namespace LinearAlgebra +namespace J3ML::LinearAlgebra { /// The CFrame is fundamentally 4 vectors (position, forward, right, up vector) class CoordinateFrame diff --git a/include/J3ML/LinearAlgebra/EulerAngle.h b/include/J3ML/LinearAlgebra/EulerAngle.h index ccd3838..54e2f22 100644 --- a/include/J3ML/LinearAlgebra/EulerAngle.h +++ b/include/J3ML/LinearAlgebra/EulerAngle.h @@ -2,7 +2,7 @@ #include #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { // Essential Reading: // http://www.essentialmath.com/GDC2012/GDC2012_JMV_Rotations.pdf diff --git a/include/J3ML/LinearAlgebra/Matrix2x2.h b/include/J3ML/LinearAlgebra/Matrix2x2.h index 2e5e242..1f7d2b7 100644 --- a/include/J3ML/LinearAlgebra/Matrix2x2.h +++ b/include/J3ML/LinearAlgebra/Matrix2x2.h @@ -3,7 +3,7 @@ #include #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { class Matrix2x2 { public: enum { Rows = 3 }; diff --git a/include/J3ML/LinearAlgebra/Matrix3x3.h b/include/J3ML/LinearAlgebra/Matrix3x3.h index 8d18501..28bb56a 100644 --- a/include/J3ML/LinearAlgebra/Matrix3x3.h +++ b/include/J3ML/LinearAlgebra/Matrix3x3.h @@ -5,7 +5,7 @@ #include #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { /// A 3-by-3 matrix for linear transformations of 3D geometry. /* This can represent any kind of linear transformations of 3D geometry, which include * rotation, scale, shear, mirroring, and orthographic projection. diff --git a/include/J3ML/LinearAlgebra/Matrix4x4.h b/include/J3ML/LinearAlgebra/Matrix4x4.h index 5fa9bd9..578aa4c 100644 --- a/include/J3ML/LinearAlgebra/Matrix4x4.h +++ b/include/J3ML/LinearAlgebra/Matrix4x4.h @@ -3,7 +3,7 @@ #include #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { /// A 4-by-4 matrix for affine transformations and perspective projections of 3D geometry. /* This matrix can represent the most generic form of transformations for 3D objects, diff --git a/include/J3ML/LinearAlgebra/Quaternion.h b/include/J3ML/LinearAlgebra/Quaternion.h index 284763c..7c09e7d 100644 --- a/include/J3ML/LinearAlgebra/Quaternion.h +++ b/include/J3ML/LinearAlgebra/Quaternion.h @@ -6,7 +6,7 @@ #include #include -namespace LinearAlgebra +namespace J3ML::LinearAlgebra { class Quaternion : public Vector4 { public: diff --git a/include/J3ML/LinearAlgebra/Transform2D.h b/include/J3ML/LinearAlgebra/Transform2D.h index 345ce4a..bdf4c33 100644 --- a/include/J3ML/LinearAlgebra/Transform2D.h +++ b/include/J3ML/LinearAlgebra/Transform2D.h @@ -3,7 +3,7 @@ #include #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { class Transform2D { protected: Matrix3x3 transformation; diff --git a/include/J3ML/LinearAlgebra/Vector2.h b/include/J3ML/LinearAlgebra/Vector2.h index 9552b96..d007503 100644 --- a/include/J3ML/LinearAlgebra/Vector2.h +++ b/include/J3ML/LinearAlgebra/Vector2.h @@ -3,7 +3,7 @@ #include #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { using namespace J3ML; diff --git a/include/J3ML/LinearAlgebra/Vector3.h b/include/J3ML/LinearAlgebra/Vector3.h index b128d6c..d55f2ed 100644 --- a/include/J3ML/LinearAlgebra/Vector3.h +++ b/include/J3ML/LinearAlgebra/Vector3.h @@ -6,7 +6,7 @@ #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { // A 3D (x, y, z) ordered pair. class Vector3 { diff --git a/include/J3ML/LinearAlgebra/Vector4.h b/include/J3ML/LinearAlgebra/Vector4.h index 0d9c12a..3dd8b9c 100644 --- a/include/J3ML/LinearAlgebra/Vector4.h +++ b/include/J3ML/LinearAlgebra/Vector4.h @@ -3,7 +3,7 @@ #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { class Vector4 { public: // Default Constructor diff --git a/src/J3ML/Geometry/Capsule.cpp b/src/J3ML/Geometry/Capsule.cpp index 1c509f8..d052bb0 100644 --- a/src/J3ML/Geometry/Capsule.cpp +++ b/src/J3ML/Geometry/Capsule.cpp @@ -1,6 +1,6 @@ #include -namespace Geometry +namespace J3ML::Geometry { Capsule::Capsule() : l() {} diff --git a/src/J3ML/Geometry/Frustum.cpp b/src/J3ML/Geometry/Frustum.cpp index b0fd005..cf2e9e2 100644 --- a/src/J3ML/Geometry/Frustum.cpp +++ b/src/J3ML/Geometry/Frustum.cpp @@ -1,6 +1,6 @@ #include -namespace Geometry +namespace J3ML::Geometry { Frustum Frustum::CreateFrustumFromCamera(const CoordinateFrame &cam, float aspect, float fovY, float zNear, float zFar) { Frustum frustum; diff --git a/src/J3ML/Geometry/LineSegment.cpp b/src/J3ML/Geometry/LineSegment.cpp index 556b643..f3015b3 100644 --- a/src/J3ML/Geometry/LineSegment.cpp +++ b/src/J3ML/Geometry/LineSegment.cpp @@ -1,6 +1,6 @@ #include -namespace Geometry { +namespace J3ML::Geometry { LineSegment::LineSegment(const Vector3 &a, const Vector3 &b) : A(a), B(b) { diff --git a/src/J3ML/LinearAlgebra/AxisAngle.cpp b/src/J3ML/LinearAlgebra/AxisAngle.cpp index 3a85944..853fd51 100644 --- a/src/J3ML/LinearAlgebra/AxisAngle.cpp +++ b/src/J3ML/LinearAlgebra/AxisAngle.cpp @@ -1,6 +1,6 @@ #include #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { AxisAngle::AxisAngle() : axis(Vector3::Zero) {} diff --git a/src/J3ML/LinearAlgebra/EulerAngle.cpp b/src/J3ML/LinearAlgebra/EulerAngle.cpp index 4f1f726..facd6dd 100644 --- a/src/J3ML/LinearAlgebra/EulerAngle.cpp +++ b/src/J3ML/LinearAlgebra/EulerAngle.cpp @@ -3,50 +3,49 @@ #include -#pragma region EulerAngle -namespace LinearAlgebra { -EulerAngle::EulerAngle(float pitch, float yaw, float roll): pitch(pitch), yaw(yaw), roll(roll) -{} +namespace J3ML::LinearAlgebra { + EulerAngle::EulerAngle(float pitch, float yaw, float roll): pitch(pitch), yaw(yaw), roll(roll) + {} -float EulerAngle::GetPitch(float pitch_limit) const -{ return std::clamp( std::remainderf(pitch,360.f), -pitch_limit, pitch_limit); } + float EulerAngle::GetPitch(float pitch_limit) const + { return std::clamp( std::remainderf(pitch,360.f), -pitch_limit, pitch_limit); } -float EulerAngle::GetYaw(float yaw_limit) const -{ return std::clamp(std::remainderf(yaw, 360.f), -yaw_limit, yaw_limit); } + float EulerAngle::GetYaw(float yaw_limit) const + { return std::clamp(std::remainderf(yaw, 360.f), -yaw_limit, yaw_limit); } -float EulerAngle::GetRoll(float pitch_limit) const -{ return std::clamp( std::remainderf(pitch,360.f), -pitch_limit, pitch_limit); } + float EulerAngle::GetRoll(float pitch_limit) const + { return std::clamp( std::remainderf(pitch,360.f), -pitch_limit, pitch_limit); } -bool EulerAngle::operator==(const EulerAngle& a) const -{ - return (pitch == a.pitch) && (yaw == a.yaw) && (roll == a.roll); -} + bool EulerAngle::operator==(const EulerAngle& a) const + { + return (pitch == a.pitch) && (yaw == a.yaw) && (roll == a.roll); + } -void EulerAngle::clamp() -{ - if (this->pitch > 89.0f) - this->pitch = 89.0f; - if (this->pitch <= -89.0f) - this->pitch = -89.0f; - //TODO: Make this entirely seamless by getting the amount they rotated passed -180 and +180 by. - if (this->yaw <= -180.0f) - this->yaw = 180.0f; - if (this->yaw >= 180.01f) - this->yaw = -179.9f; - if (this->roll >= 360.0f) - this->roll = 0.0; - if (this->roll <= -360.0f) - this->roll = 0.0; -} + void EulerAngle::clamp() + { + if (this->pitch > 89.0f) + this->pitch = 89.0f; + if (this->pitch <= -89.0f) + this->pitch = -89.0f; + //TODO: Make this entirely seamless by getting the amount they rotated passed -180 and +180 by. + if (this->yaw <= -180.0f) + this->yaw = 180.0f; + if (this->yaw >= 180.01f) + this->yaw = -179.9f; + if (this->roll >= 360.0f) + this->roll = 0.0; + if (this->roll <= -360.0f) + this->roll = 0.0; + } -EulerAngle EulerAngle::movementAngle() const -{ - EulerAngle a; - a.pitch = (cos(Math::Radians(yaw)) * cos(Math::Radians(pitch))); - a.yaw = -sin(Math::Radians(pitch)); - a.roll = (sin(Math::Radians(yaw)) * cos(Math::Radians(pitch))); - return a; -} + EulerAngle EulerAngle::movementAngle() const + { + EulerAngle a; + a.pitch = (cos(Math::Radians(yaw)) * cos(Math::Radians(pitch))); + a.yaw = -sin(Math::Radians(pitch)); + a.roll = (sin(Math::Radians(yaw)) * cos(Math::Radians(pitch))); + return a; + } EulerAngle::EulerAngle() : pitch(0), yaw(0), roll(0) {} } \ No newline at end of file diff --git a/src/J3ML/LinearAlgebra/Matrix2x2.cpp b/src/J3ML/LinearAlgebra/Matrix2x2.cpp index 9f13257..088b2d5 100644 --- a/src/J3ML/LinearAlgebra/Matrix2x2.cpp +++ b/src/J3ML/LinearAlgebra/Matrix2x2.cpp @@ -1,6 +1,6 @@ #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { Vector2 Matrix2x2::GetRow(int index) const { float x = this->elems[index][0]; diff --git a/src/J3ML/LinearAlgebra/Matrix3x3.cpp b/src/J3ML/LinearAlgebra/Matrix3x3.cpp index 0fd58d1..8e0cfc5 100644 --- a/src/J3ML/LinearAlgebra/Matrix3x3.cpp +++ b/src/J3ML/LinearAlgebra/Matrix3x3.cpp @@ -1,7 +1,7 @@ #include #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { const Matrix3x3 Matrix3x3::Zero = Matrix3x3(0, 0, 0, 0, 0, 0, 0, 0, 0); const Matrix3x3 Matrix3x3::Identity = Matrix3x3(1, 0, 0, 0, 1, 0, 0, 0, 1); diff --git a/src/J3ML/LinearAlgebra/Matrix4x4.cpp b/src/J3ML/LinearAlgebra/Matrix4x4.cpp index fae41b5..5be8901 100644 --- a/src/J3ML/LinearAlgebra/Matrix4x4.cpp +++ b/src/J3ML/LinearAlgebra/Matrix4x4.cpp @@ -1,7 +1,7 @@ #include #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { const Matrix4x4 Matrix4x4::Zero = Matrix4x4(0); const Matrix4x4 Matrix4x4::Identity = Matrix4x4({1,0,0,0}, {0,1,0,0}, {0,0,1,0}, {0,0,0,1}); const Matrix4x4 Matrix4x4::NaN = Matrix4x4(NAN); diff --git a/src/J3ML/LinearAlgebra/Quaternion.cpp b/src/J3ML/LinearAlgebra/Quaternion.cpp index 6fd2667..27ee94f 100644 --- a/src/J3ML/LinearAlgebra/Quaternion.cpp +++ b/src/J3ML/LinearAlgebra/Quaternion.cpp @@ -4,7 +4,7 @@ #include #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { Quaternion Quaternion::operator-() const { return {-x, -y, -z, -w}; diff --git a/src/J3ML/LinearAlgebra/Transform2D.cpp b/src/J3ML/LinearAlgebra/Transform2D.cpp index 151aa28..b56ee9b 100644 --- a/src/J3ML/LinearAlgebra/Transform2D.cpp +++ b/src/J3ML/LinearAlgebra/Transform2D.cpp @@ -1,6 +1,6 @@ #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { const Transform2D Transform2D::Identity = Transform2D({0, 0}, {1, 1}, {0,0}, {0,0}, 0); const Transform2D Transform2D::FlipX = Transform2D({0, 0}, {-1, 1}, {0,0}, {0,0}, 0); diff --git a/src/J3ML/LinearAlgebra/Vector2.cpp b/src/J3ML/LinearAlgebra/Vector2.cpp index 5949c05..388d578 100644 --- a/src/J3ML/LinearAlgebra/Vector2.cpp +++ b/src/J3ML/LinearAlgebra/Vector2.cpp @@ -4,7 +4,7 @@ #include #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { Vector2::Vector2(): x(0), y(0) {} diff --git a/src/J3ML/LinearAlgebra/Vector3.cpp b/src/J3ML/LinearAlgebra/Vector3.cpp index 35bee33..295ce3c 100644 --- a/src/J3ML/LinearAlgebra/Vector3.cpp +++ b/src/J3ML/LinearAlgebra/Vector3.cpp @@ -3,9 +3,9 @@ #include #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { + -#pragma region vector3 const Vector3 Vector3::Zero = {0,0,0}; const Vector3 Vector3::Up = {0, -1, 0}; @@ -308,5 +308,5 @@ namespace LinearAlgebra { return {x, y, z}; } -#pragma endregion + } \ No newline at end of file diff --git a/src/J3ML/LinearAlgebra/Vector4.cpp b/src/J3ML/LinearAlgebra/Vector4.cpp index fb735dc..c1c11b9 100644 --- a/src/J3ML/LinearAlgebra/Vector4.cpp +++ b/src/J3ML/LinearAlgebra/Vector4.cpp @@ -7,7 +7,7 @@ #include #include -namespace LinearAlgebra { +namespace J3ML::LinearAlgebra { const Vector4 Vector4::Zero = {0,0,0,0}; const Vector4 Vector4::NaN = {NAN, NAN, NAN, NAN}; diff --git a/tests/LinearAlgebra/Vector2Tests.cpp b/tests/LinearAlgebra/Vector2Tests.cpp index a9213f5..cd557f2 100644 --- a/tests/LinearAlgebra/Vector2Tests.cpp +++ b/tests/LinearAlgebra/Vector2Tests.cpp @@ -1,7 +1,7 @@ #include #include -using Vector2 = LinearAlgebra::Vector2; +using J3ML::LinearAlgebra::Vector2; TEST(Vector2Test, V2_Constructor_Default) { diff --git a/tests/LinearAlgebra/Vector3Tests.cpp b/tests/LinearAlgebra/Vector3Tests.cpp index 11e5974..505372a 100644 --- a/tests/LinearAlgebra/Vector3Tests.cpp +++ b/tests/LinearAlgebra/Vector3Tests.cpp @@ -1,7 +1,7 @@ #include #include -using Vector3 = LinearAlgebra::Vector3; +using J3ML::LinearAlgebra::Vector3; void EXPECT_V3_EQ(const Vector3& lhs, const Vector3& rhs) { @@ -185,11 +185,12 @@ TEST(Vector3Test, V3_Lerp) EXPECT_V3_EQ(Start.Lerp(Finish, Percent), ExpectedResult); } TEST(Vector3Test, V3_AngleBetween) { + using J3ML::LinearAlgebra::Angle2D; Vector3 A{ .5f, .5f, .5f}; Vector3 B {.25f, .75f, .25f}; A = A.Normalize(); B = B.Normalize(); - LinearAlgebra::Angle2D ExpectedResult {-0.69791365, -2.3561945}; + Angle2D ExpectedResult {-0.69791365, -2.3561945}; std::cout << A.AngleBetween(B).x << ", " << A.AngleBetween(B).y << ""; auto angle = A.AngleBetween(B); EXPECT_FLOAT_EQ(angle.x, ExpectedResult.x); diff --git a/tests/LinearAlgebra/Vector4Tests.cpp b/tests/LinearAlgebra/Vector4Tests.cpp index 1ab861b..a87c752 100644 --- a/tests/LinearAlgebra/Vector4Tests.cpp +++ b/tests/LinearAlgebra/Vector4Tests.cpp @@ -1,7 +1,7 @@ #include #include -using Vector4 = LinearAlgebra::Vector4; +using Vector4 = J3ML::LinearAlgebra::Vector4; void EXPECT_V4_EQ(const Vector4& lhs, const Vector4& rhs)