Implementing Vector3 Unit Tests
This commit is contained in:
@@ -152,6 +152,7 @@ namespace LinearAlgebra {
|
||||
auto m21 = this->elems[2][1];
|
||||
auto m22 = this->elems[2][2];
|
||||
|
||||
// NO: This is correct order for transposition!
|
||||
return {
|
||||
m00, m10, m20,
|
||||
m01, m11, m21,
|
||||
@@ -162,7 +163,7 @@ namespace LinearAlgebra {
|
||||
Vector2 Matrix3x3::Transform(const Vector2 &rhs) const {
|
||||
return {
|
||||
At(0,0) * rhs.x + At(0, 1) * rhs.y,
|
||||
At(1, 0) * rhs.x + At(1, 1) * rhs.y
|
||||
At(1,0) * rhs.x + At(1, 1) * rhs.y
|
||||
};
|
||||
}
|
||||
|
||||
|
@@ -2,6 +2,7 @@
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <valarray>
|
||||
#include <iostream>
|
||||
|
||||
namespace LinearAlgebra {
|
||||
|
||||
@@ -115,6 +116,7 @@ namespace LinearAlgebra {
|
||||
{
|
||||
auto numer = this->Dot(rhs);
|
||||
auto denom = this->Magnitude() * rhs.Magnitude();
|
||||
std::cout << numer << ", " << denom << std::endl;
|
||||
return std::acos(numer / denom);
|
||||
}
|
||||
|
||||
@@ -198,5 +200,37 @@ namespace LinearAlgebra {
|
||||
|
||||
Vector2 Vector2::Lerp(const Vector2 &lhs, const Vector2 &rhs, float alpha) { return lhs.Lerp(rhs, alpha); }
|
||||
|
||||
Vector2 Vector2::Div(const Vector2 &lhs, float rhs) {
|
||||
return lhs.Div(rhs);
|
||||
}
|
||||
|
||||
Vector2 Vector2::Mul(const Vector2 &lhs, float rhs) {
|
||||
return lhs.Mul(rhs);
|
||||
}
|
||||
|
||||
Vector2 Vector2::Sub(const Vector2 &lhs, const Vector2 &rhs) {
|
||||
return lhs.Sub(rhs);
|
||||
}
|
||||
|
||||
Vector2 Vector2::Add(const Vector2 &lhs, const Vector2 &rhs) {
|
||||
return lhs.Add(rhs);
|
||||
}
|
||||
|
||||
Vector2 Vector2::Add(const Vector2 &rhs) const {
|
||||
return *this + rhs;
|
||||
}
|
||||
|
||||
Vector2 Vector2::Sub(const Vector2 &rhs) const {
|
||||
return *this - rhs;
|
||||
}
|
||||
|
||||
Vector2 Vector2::Mul(float scalar) const {
|
||||
return *this * scalar;
|
||||
}
|
||||
|
||||
Vector2 Vector2::Div(float scalar) const {
|
||||
return *this / scalar;
|
||||
}
|
||||
|
||||
|
||||
}
|
@@ -14,6 +14,7 @@ namespace LinearAlgebra {
|
||||
const Vector3 Vector3::Right = {1, 0, 0};
|
||||
const Vector3 Vector3::Forward = {0, 0, -1};
|
||||
const Vector3 Vector3::Backward = {0, 0, 1};
|
||||
const Vector3 Vector3::NaN = {NAN, NAN, NAN};
|
||||
|
||||
Vector3 Vector3::operator+(const Vector3& rhs) const
|
||||
{
|
||||
@@ -231,5 +232,61 @@ namespace LinearAlgebra {
|
||||
return std::abs(LengthSquared()-1.f) <= epsilonSq;
|
||||
}
|
||||
|
||||
Vector3 Vector3::Cross(const Vector3 &lhs, const Vector3 &rhs) {
|
||||
return lhs.Cross(rhs);
|
||||
}
|
||||
|
||||
Vector3 Vector3::Normalize(const Vector3 &targ) {
|
||||
return targ.Normalize();
|
||||
}
|
||||
|
||||
Vector3 Vector3::Project(const Vector3 &lhs, const Vector3 &rhs) {
|
||||
return lhs.Project(rhs);
|
||||
}
|
||||
|
||||
float Vector3::Dot(const Vector3 &lhs, const Vector3 &rhs) {
|
||||
return lhs.Dot(rhs);
|
||||
}
|
||||
|
||||
float Vector3::Magnitude(const Vector3 &of) {
|
||||
return of.Magnitude();
|
||||
}
|
||||
|
||||
Vector3 Vector3::Lerp(const Vector3 &lhs, const Vector3 &rhs, float alpha) {
|
||||
return lhs.Lerp(rhs, alpha);
|
||||
}
|
||||
|
||||
Vector3 Vector3::Add(const Vector3 &lhs, const Vector3 &rhs) {
|
||||
return lhs.Add(rhs);
|
||||
}
|
||||
|
||||
Vector3 Vector3::Add(const Vector3 &rhs) const {
|
||||
return *this + rhs;
|
||||
}
|
||||
|
||||
Vector3 Vector3::Sub(const Vector3 &rhs) const {
|
||||
return *this - rhs;
|
||||
}
|
||||
|
||||
Vector3 Vector3::Sub(const Vector3 &lhs, const Vector3 &rhs) {
|
||||
lhs.Sub(rhs);
|
||||
}
|
||||
|
||||
Vector3 Vector3::Mul(float scalar) const {
|
||||
return *this * scalar;
|
||||
}
|
||||
|
||||
Vector3 Vector3::Mul(const Vector3 &lhs, float rhs) {
|
||||
return lhs.Mul(rhs);
|
||||
}
|
||||
|
||||
Vector3 Vector3::Div(float scalar) const {
|
||||
return *this / scalar;
|
||||
}
|
||||
|
||||
Vector3 Vector3::Div(const Vector3 &lhs, float rhs) {
|
||||
return lhs.Div(rhs);
|
||||
}
|
||||
|
||||
#pragma endregion
|
||||
}
|
Reference in New Issue
Block a user