mirror of
https://github.com/orange-cpp/omath.git
synced 2026-02-13 15:03:27 +00:00
25 lines
373 B
C++
25 lines
373 B
C++
//
|
|
// Created by Vlad on 02.09.2024.
|
|
//
|
|
#include "omath/Vector2.h"
|
|
#include <cmath>
|
|
|
|
|
|
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);
|
|
}
|
|
} |