22 lines
621 B
C++
22 lines
621 B
C++
#include "transforms.hpp"
|
|
#include "constants.hpp"
|
|
#include <cmath>
|
|
|
|
math::Vector math::RotatePoint(const Vector& center, float angle, const Vector& p)
|
|
{
|
|
const float sina = std::sin(angle);
|
|
const float cosa = std::cos(angle);
|
|
const Vector p1 = p - center;
|
|
return Vector(p1.x * cosa - p1.y * sina, p1.x * sina + p1.y * cosa) + center;
|
|
}
|
|
|
|
math::Vector math::ScalePoint(const Vector& center, float factor, const Vector& p)
|
|
{
|
|
return ((p - center) * factor) + center;
|
|
}
|
|
|
|
float math::RotateAngle(float originalAngle, float rotationAngle)
|
|
{
|
|
return std::fmodf(originalAngle + rotationAngle, PI * 2.0f);
|
|
}
|