Implementing Vector3 Unit Tests

This commit is contained in:
2024-01-02 21:31:44 -05:00
parent 09922ac0bd
commit 7429f0782f
5 changed files with 123 additions and 46 deletions

View File

@@ -116,7 +116,6 @@ namespace LinearAlgebra {
{
auto numer = this->Dot(rhs);
auto denom = this->Magnitude() * rhs.Magnitude();
std::cout << numer << ", " << denom << std::endl;
return std::acos(numer / denom);
}

View File

@@ -269,7 +269,7 @@ namespace LinearAlgebra {
}
Vector3 Vector3::Sub(const Vector3 &lhs, const Vector3 &rhs) {
lhs.Sub(rhs);
return lhs.Sub(rhs);
}
Vector3 Vector3::Mul(float scalar) const {
@@ -288,5 +288,18 @@ namespace LinearAlgebra {
return lhs.Div(rhs);
}
Angle2D Vector3::AngleBetween(const Vector3 &rhs) const {
const auto Pi_x_180 = 180.f / M_PI;
auto dist = this->Distance(rhs);
float x = -(asinf((rhs.y - this->y) / dist));
float y = (atan2f(rhs.x - this->x,rhs.z - this->z));
return {x, y};
}
Angle2D Vector3::AngleBetween(const Vector3 &lhs, const Vector3 &rhs) // TODO: 3D Angle representation?
{
return lhs.AngleBetween(rhs);
}
#pragma endregion
}