X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fgraphics%2FVector.h;h=50ae8c8de067b184e7d49888c7c31c457fd724ef;hb=refs%2Fheads%2Fmaster;hp=0fd5bfe49f84d878a688df600b919b29f8cc367e;hpb=962405ec344818a7f6850d243feca7989ae5d41b;p=orbi.git diff --git a/src/graphics/Vector.h b/src/graphics/Vector.h index 0fd5bfe..50ae8c8 100644 --- a/src/graphics/Vector.h +++ b/src/graphics/Vector.h @@ -164,6 +164,14 @@ constexpr Vector abs(Vector v) { return Vector(std::abs(v.x), std::abs(v.y)); } template +inline Vector round(Vector v) { + return Vector(std::round(v.x), std::round(v.y)); +} +template<> +inline Vector round(Vector v) { + return Vector(std::roundf(v.x), std::roundf(v.y)); +} +template constexpr Vector min(Vector lhs, Vector rhs) { return Vector(std::min(lhs.x, rhs.x), std::min(lhs.y, rhs.y)); } @@ -190,6 +198,15 @@ constexpr Vector Norm(Vector v) { return v / Length(v); } +template +constexpr Vector MirrorX(Vector v) { + return Vector(v.x, -v.y); +} +template +constexpr Vector MirrorY(Vector v) { + return Vector(-v.x, v.y); +} + template constexpr Vector Rotate90(Vector v) { return Vector(-v.y, v.x); @@ -202,6 +219,7 @@ template constexpr Vector Rotate270(Vector v) { return Vector(v.y, -v.x); } +// angle given in radians template inline Vector Rotate(Vector v, Float by) { Float sine(std::sin(by));