Adding code x3
This commit is contained in:
@@ -14,8 +14,6 @@ namespace LinearAlgebra
|
||||
|
||||
public:
|
||||
AxisAngle();
|
||||
AxisAngle(Vector3 axis, float angle);
|
||||
|
||||
|
||||
AxisAngle(const Vector3& axis, float angle);
|
||||
};
|
||||
}
|
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector4.h>
|
||||
#include <J3ML/LinearAlgebra/AxisAngle.h>
|
||||
#include <J3ML/LinearAlgebra/Matrix3x3.h>
|
||||
|
||||
namespace LinearAlgebra
|
||||
{
|
||||
@@ -17,8 +18,6 @@ namespace LinearAlgebra
|
||||
// @note The input data is not normalized after construction, this has to be done manually.
|
||||
Quaternion(float X, float Y, float Z, float W);
|
||||
|
||||
|
||||
|
||||
// Constructs this quaternion by specifying a rotation axis and the amount of rotation to be performed about that axis
|
||||
// @param rotationAxis The normalized rotation axis to rotate about. If using Vector4 version of the constructor, the w component of this vector must be 0.
|
||||
Quaternion(const Vector3& rotationAxis, float rotationAngleBetween) { SetFromAxisAngle(rotationAxis, rotationAngleBetween); }
|
||||
@@ -71,7 +70,7 @@ namespace LinearAlgebra
|
||||
Vector4 operator * (const Vector4& rhs) const;
|
||||
|
||||
// Divides a quaternion by another. Divison "a / b" results in a quaternion that rotates the orientation b to coincide with orientation of
|
||||
//Quaternion operator / (const Quaternion& rhs) const;
|
||||
Quaternion operator / (const Quaternion& rhs) const;
|
||||
Quaternion operator +(const Quaternion& rhs) const;
|
||||
Quaternion operator +() const;
|
||||
Quaternion operator -() const;
|
||||
|
@@ -16,7 +16,6 @@ namespace LinearAlgebra {
|
||||
Vector4(Vector4&& move) = default;
|
||||
Vector4& operator=(const Vector4& rhs);
|
||||
|
||||
|
||||
float GetX() const;
|
||||
float GetY() const;
|
||||
float GetZ() const;
|
||||
|
11
main.cpp
11
main.cpp
@@ -5,4 +5,13 @@ int main(int argc, char** argv)
|
||||
{
|
||||
std::cout << "j3ml demo coming soon" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __WIN32
|
||||
extern "C" {
|
||||
int wmain(int argc, wchar_t* argv[])
|
||||
{
|
||||
return main(argc, reinterpret_cast<char **>(argv));
|
||||
}
|
||||
};
|
||||
#endif
|
@@ -47,4 +47,6 @@ EulerAngle EulerAngle::movementAngle() const
|
||||
a.roll = (sin(Math::Radians(yaw)) * cos(Math::Radians(pitch)));
|
||||
return a;
|
||||
}
|
||||
|
||||
EulerAngle::EulerAngle() : pitch(0), yaw(0), roll(0) {}
|
||||
}
|
@@ -135,11 +135,34 @@ namespace LinearAlgebra {
|
||||
y*reciprocalSinAngle,
|
||||
z*reciprocalSinAngle
|
||||
};
|
||||
return {axis, angle};
|
||||
return AxisAngle(axis, angle);
|
||||
}
|
||||
|
||||
float Quaternion::AngleBetween(const Quaternion &target) const {
|
||||
Quaternion delta = target / *this;
|
||||
return delta.Normalize().Angle();
|
||||
}
|
||||
|
||||
Quaternion Quaternion::operator/(const Quaternion &rhs) const {
|
||||
return {
|
||||
x*rhs.w - y*rhs.z + z*rhs.y - w*rhs.x,
|
||||
x*rhs.z + y*rhs.w - z*rhs.x - w*rhs.y,
|
||||
-x*rhs.y + y*rhs.x + z*rhs.w - w*rhs.z,
|
||||
x*rhs.x + y*rhs.y + z*rhs.z + w*rhs.w
|
||||
};
|
||||
}
|
||||
|
||||
Matrix3x3 Quaternion::ToMatrix3x3() const {
|
||||
return {
|
||||
1 - 2 *(y*y) - 2*(z*z), 2*x*y - 2*z*w, 2*x*z + 2*y*w,
|
||||
2*x*y + 2*z*w, 1-2*x*x - 2*z*z, 2*y*z - 2*x*w,
|
||||
2*x*z - 2*y*w, 2*y*z + 2*x*w, 1-2*x*x - 2*y*y
|
||||
};
|
||||
}
|
||||
|
||||
Quaternion Quaternion::operator+(const Quaternion &rhs) const {
|
||||
return {
|
||||
x + rhs.x, y + rhs.y, z + rhs.z,w + rhs.w
|
||||
};
|
||||
}
|
||||
}
|
@@ -1,6 +1,9 @@
|
||||
#include <J3ML/LinearAlgebra/Vector4.h>
|
||||
|
||||
#pragma region vector4
|
||||
|
||||
|
||||
#include <J3ML/LinearAlgebra/Vector4.h>
|
||||
#include <J3ML/LinearAlgebra/Vector3.h>
|
||||
#include <cmath>
|
||||
#include <algorithm>
|
||||
|
||||
@@ -131,6 +134,11 @@ Vector4 Vector4::operator-(const Vector4& rhs) const
|
||||
return this->Distance(rhs) <= margin;
|
||||
}
|
||||
|
||||
Vector4::Vector4(const Vector3 &xyz, float w) : x(xyz.x), y(xyz.y), z(xyz.z), w(w)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
#pragma endregion
|
@@ -10,10 +10,10 @@ add_library(GTest::GTest INTERFACE IMPORTED)
|
||||
target_link_libraries(GTest::GTest INTERFACE gtest_main)
|
||||
|
||||
|
||||
file(GLOB_RECURSE TEST_SRC "*.cpp")
|
||||
file(GLOB_RECURSE TEST_SRC "tests.cpp" "*.cpp")
|
||||
add_executable(Test ${TEST_SRC})
|
||||
target_link_libraries(Test PUBLIC J3ML)
|
||||
#find_package(GTest REQUIRED)
|
||||
target_link_libraries(Test PRIVATE GTest::GTest)
|
||||
include_directories("include")
|
||||
add_test(NAME "J3MLTestSuite" COMMAND J3MLTestSuite)
|
||||
add_test(NAME "J3MLTestSuite" COMMAND Test)
|
@@ -2,27 +2,24 @@
|
||||
#include <J3ML/LinearAlgebra/Vector2.h>
|
||||
|
||||
|
||||
TEST(Vector2Test, V2_Constructor_Default) { }
|
||||
TEST(Vector2Test, V2_Constructor_Default)
|
||||
{
|
||||
EXPECT_EQ(LinearAlgebra::Vector2(), LinearAlgebra::Vector2::Up);
|
||||
}
|
||||
|
||||
/*
|
||||
TEST(Vector2Test, V2_Addition) { }
|
||||
TEST(Vector2Test, V2_Subtraction) { }
|
||||
TEST(Vector2Test, V2_Multiplication) { }
|
||||
TEST(Vector2Test, V2_Division) { }
|
||||
TEST(Vector2Test, V2_Equality) { }
|
||||
TEST(Vector2Test, V2_Array_Operator_Indexing) { }
|
||||
|
||||
|
||||
TEST(Vector2Test, V2_Normalize)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector2Test, V2_Dot)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector2Test, V2_Normalize) { }
|
||||
TEST(Vector2Test, V2_Dot) { }
|
||||
TEST(Vector2Test, V2_Min) { }
|
||||
TEST(Vector2Test, V2_Max) { }
|
||||
TEST(Vector2Test, V2_Distance) { }
|
||||
TEST(Vector2Test, V2_Length) { }
|
||||
TEST(Vector2Test, V2_Clamp) { }
|
||||
TEST(Vector2Test, V2_Clamp) { }
|
||||
|
||||
*/
|
@@ -4,4 +4,13 @@
|
||||
GTEST_API_ int main(int argc, char** argv) {
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __WIN32
|
||||
extern "C" {
|
||||
int wmain(int argc, wchar_t* argv[])
|
||||
{
|
||||
return main(argc, reinterpret_cast<char **>(argv));
|
||||
}
|
||||
};
|
||||
#endif
|
Reference in New Issue
Block a user