Implement Transform2D.h
This commit is contained in:
@@ -125,6 +125,7 @@ namespace LinearAlgebra {
|
||||
Vector2 Transform(const Vector2& rhs) const;
|
||||
Vector3 Transform(const Vector3& rhs) const;
|
||||
|
||||
Vector2 operator * (const Vector2& rhs) const;
|
||||
Vector3 operator * (const Vector3& rhs) const;
|
||||
Matrix3x3 operator * (const Matrix3x3& rhs) const;
|
||||
|
||||
|
@@ -37,6 +37,20 @@ namespace LinearAlgebra
|
||||
Vector3 GetWorldY() const;
|
||||
Vector3 GetWorldZ() const;
|
||||
|
||||
Vector3 GetAxis() const
|
||||
{
|
||||
float rcpSinAngle = 1 - (std::sqrt(1 - w * w));
|
||||
|
||||
return Vector3(x, y, z) * rcpSinAngle;
|
||||
}
|
||||
|
||||
float GetAngle() const
|
||||
{
|
||||
return std::acos(w) * 2.f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Matrix3x3 ToMatrix3x3() const;
|
||||
|
||||
Vector3 Transform(const Vector3& vec) const;
|
||||
@@ -57,7 +71,6 @@ namespace LinearAlgebra
|
||||
// TODO: Document (But do not override!) certain math functions that are the same for Vec4
|
||||
// TODO: Double Check which operations need to be overriden for correct behavior!
|
||||
|
||||
|
||||
// Multiplies two quaternions together.
|
||||
// The product q1 * q2 returns a quaternion that concatenates the two orientation rotations.
|
||||
// The rotation q2 is applied first before q1.
|
||||
@@ -71,9 +84,9 @@ namespace LinearAlgebra
|
||||
|
||||
// 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 operator -() const;
|
||||
Quaternion operator + (const Quaternion& rhs) const;
|
||||
Quaternion operator + () const;
|
||||
Quaternion operator - () const;
|
||||
float Dot(const Quaternion &quaternion) const;
|
||||
|
||||
float Angle() const;
|
||||
|
@@ -14,6 +14,11 @@ namespace LinearAlgebra {
|
||||
Transform2D Scale(float x, float y); // Perform Nonunform Scale
|
||||
Transform2D Scale(const Vector2& scales); // Perform Nonuniform Scale
|
||||
Transform2D Rotate();
|
||||
|
||||
Vector2 Transform(const Vector2& input) const
|
||||
{
|
||||
return transformation * input;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -60,16 +60,14 @@ namespace LinearAlgebra {
|
||||
Quaternion::Quaternion(float X, float Y, float Z, float W) : Vector4(X,Y,Z,W) {}
|
||||
|
||||
// TODO: implement
|
||||
float Quaternion::Dot(const Quaternion &quaternion) const {}
|
||||
float Quaternion::Dot(const Quaternion &rhs) const {
|
||||
return x * rhs.x + y * rhs.y + z * rhs.z + w * rhs.w;
|
||||
}
|
||||
|
||||
Quaternion::Quaternion(Vector4 vector4) {
|
||||
|
||||
}
|
||||
|
||||
float Quaternion::Angle() const {
|
||||
return std::acos(w) * 2.f;
|
||||
}
|
||||
|
||||
Quaternion Quaternion::Normalize() const {
|
||||
float length = Length();
|
||||
if (length < 1e-4f)
|
||||
|
@@ -1,3 +1,106 @@
|
||||
//
|
||||
// Created by josh on 12/26/2023.
|
||||
//
|
||||
#include <gtest/gtest.h>
|
||||
#include <J3ML/LinearAlgebra/Vector4.h>
|
||||
|
||||
using Vector4 = LinearAlgebra::Vector4;
|
||||
|
||||
|
||||
void EXPECT_V4_EQ(const Vector4& lhs, const Vector4& rhs)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Constructor_Default)
|
||||
{
|
||||
EXPECT_V4_EQ(Vector4(), Vector4::Zero);
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Constructor_XYZW)
|
||||
{
|
||||
Vector4 Input {0, 1, 0, 1};
|
||||
EXPECT_FLOAT_EQ(Input.x, 0);
|
||||
EXPECT_FLOAT_EQ(Input.y, 1);
|
||||
EXPECT_FLOAT_EQ(Input.z, 0);
|
||||
EXPECT_FLOAT_EQ(Input.w, 1);
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Addition_Op) {
|
||||
Vector4 A {1, 1, 1, 1};
|
||||
Vector4 B {2, 2, 2, 2};
|
||||
|
||||
Vector4 ExpectedResult {3, 3, 3, 3};
|
||||
|
||||
EXPECT_V4_EQ(A + B, ExpectedResult);
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Addition_Method)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Addition_Static)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Subtract_Op)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Subtract_Method)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Subtract_Static)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Scalar_Mult_Op)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Scalar_Mult_Method)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Scalar_Mult_Static)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Scalar_Div_Op)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Scalar_Div_Method)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Scalar_Div_Static)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_Sizeof)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector4Test, V4_NaN)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
TEST(Vector4Tests, V4_Min) {}
|
||||
TEST(Vector4Tests, V4_Max) {}
|
||||
TEST(Vector4Tests, V4_Clamp) {}
|
||||
TEST(Vector4Tests, V4_DotProduct) {}
|
||||
TEST(Vector4Tests, V4_CrossProduct) {}
|
||||
TEST(Vector4Tests, V4_Project) {}
|
||||
TEST(Vector4Test, V4_Normalize) {}
|
Reference in New Issue
Block a user