Point2D.hpp

A simple class to track value pairs of any kind, optimized for points in 2D Space.

Note

For maximal efficiency, prefer SquareMagnitude() and SquareDistance() over Magnitude() and Distance() as the latter require a square-root.

Typedefs

using Point = Point2D<>
template<typename TYPE = double>
class Point2D
#include <Point2D.hpp>

Public Functions

inline constexpr Point2D()
inline constexpr Point2D(const Point2D &_in)
inline constexpr Point2D(TYPE _x, TYPE _y)
inline constexpr Point2D(const Point2D &_in, TYPE new_magnitude)
inline const Point2D &operator=(const Point2D &_in)
inline constexpr bool operator==(const Point2D &_in) const
inline constexpr bool operator!=(const Point2D &_in) const
inline constexpr bool operator<=(const Point2D &_in) const
inline constexpr bool operator>=(const Point2D &_in) const
inline constexpr TYPE GetX() const
inline constexpr TYPE GetY() const
inline Point2D &SetX(TYPE in_x)
inline Point2D &SetY(TYPE in_y)
inline Point2D &Set(TYPE _x, TYPE _y)
inline constexpr double SquareMagnitude() const
inline constexpr double Magnitude() const
inline constexpr bool AtOrigin() const
inline constexpr bool NonZero() const
inline constexpr Point2D GetMidpoint(const Point2D &p2) const
inline constexpr Point2D GetRot90() const
inline constexpr Point2D GetRot180() const
inline constexpr Point2D GetRot270() const
inline constexpr Point2D GetOffset(TYPE off_x, TYPE off_y) const
inline constexpr Point2D operator+(const Point2D &_in) const
inline constexpr Point2D operator-(const Point2D &_in) const
inline constexpr Point2D operator*(double mult) const
inline constexpr Point2D operator/(double div) const
inline constexpr Point2D operator*(int mult) const
inline constexpr Point2D operator/(int div) const
inline constexpr Point2D operator-() const
inline constexpr Point2D Abs() const
inline Point2D &Translate(TYPE shift_x, TYPE shift_y)
inline Point2D &TranslateX(TYPE shift)
inline Point2D &TranslateY(TYPE shift)
inline Point2D &Scale(double scale)
inline Point2D &Scale(double scale_x, double scale_y)
inline Point2D &ToOrigin()
inline Point2D &NegateX()
inline Point2D &NegateY()
inline Point2D &Mod(const Point2D &limits)
inline Point2D &operator+=(const Point2D &_in)
inline Point2D &operator-=(const Point2D &_in)
inline Point2D &operator*=(double mult)
inline Point2D &operator/=(double val)
inline Point2D &operator*=(int mult)
inline Point2D &operator/=(int val)
inline Point2D &Rot90()
inline Point2D &Rot180()
inline Point2D &Rot270()
inline TYPE SquareDistance(const Point2D &_in) const
inline TYPE Distance(const Point2D &_in) const

Private Members

TYPE x
TYPE y