mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 07:03:25 +00:00
fixed some stuff added constexpr
This commit is contained in:
@@ -8,18 +8,4 @@
|
||||
namespace omath
|
||||
{
|
||||
|
||||
Vector2 Vector2::Normalized() const
|
||||
{
|
||||
const float len = Length();
|
||||
|
||||
if (len > 0.f)
|
||||
return {x / len, y / len};
|
||||
|
||||
return {0.f, 0.f};
|
||||
}
|
||||
|
||||
float Vector2::Length() const
|
||||
{
|
||||
return std::sqrt(x * x + y * y);
|
||||
}
|
||||
}
|
||||
@@ -8,23 +8,6 @@
|
||||
|
||||
namespace omath
|
||||
{
|
||||
|
||||
float Vector3::DistTo(const Vector3 &vOther) const
|
||||
{
|
||||
return (*this - vOther).Length();
|
||||
}
|
||||
|
||||
float Vector3::Length() const
|
||||
{
|
||||
return std::sqrt(Vector2::LengthSqr() + z * z);
|
||||
}
|
||||
|
||||
|
||||
float Vector3::Length2D() const
|
||||
{
|
||||
return Vector2::Length();
|
||||
}
|
||||
|
||||
Vector3 Vector3::ViewAngleTo(const Vector3 &other) const
|
||||
{
|
||||
const float distance = DistTo(other);
|
||||
@@ -83,12 +66,4 @@ namespace omath
|
||||
{
|
||||
return RightVector(pitch, yaw, roll).Cross(ForwardVector(pitch, yaw));
|
||||
}
|
||||
|
||||
|
||||
Vector3 Vector3::Normalized() const
|
||||
{
|
||||
const float length = this->Length();
|
||||
|
||||
return length != 0 ? *this / length : *this;
|
||||
}
|
||||
}
|
||||
@@ -32,7 +32,7 @@ namespace omath::projection
|
||||
return Mat<4, 4>::TranslationMat(-m_origin) * Mat<4, 4>::OrientationMat(forward, right, up);
|
||||
}
|
||||
|
||||
std::expected<Vector2, Error> Camera::WorldToScreen(Vector3 worldPosition) const
|
||||
std::expected<Vector3, Error> Camera::WorldToScreen(const Vector3& worldPosition) const
|
||||
{
|
||||
const auto posVecAsMatrix = Mat<1, 4>({{worldPosition.x, worldPosition.y, worldPosition.z, 1.f}});
|
||||
|
||||
@@ -54,6 +54,6 @@ namespace omath::projection
|
||||
|
||||
projected *= Mat<4, 4>::ToScreenMat(m_viewPort.m_width, m_viewPort.m_height);
|
||||
|
||||
return Vector2{projected.At(0, 0), projected.At(0, 1)};
|
||||
return Vector3{projected.At(0, 0), projected.At(0, 1), projected.At(0, 2)};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user