21template <
typename DataType>
61 x =
static_cast<DataType
>(
x * scale);
62 y =
static_cast<DataType
>(
y * scale);
69 x =
static_cast<DataType
>(
x / scale);
70 y =
static_cast<DataType
>(
y / scale);
77 static_assert(std::is_signed_v<DataType>);
84 return std::abs(
x) <= std::numeric_limits<DataType>::epsilon() &&
85 std::abs(
y) <= std::numeric_limits<DataType>::epsilon();
90template <
typename To,
typename From>
93 return {
static_cast<To
>(point.
x),
static_cast<To
>(point.
y) };
96template <
typename DataType>
99 return lhs.x == rhs.x && lhs.y == rhs.y;
102template <
typename DataType>
105 return !(lhs == rhs);
108template <
typename DataType>
112 return { lhs.x + rhs.x, lhs.y + rhs.y };
115template <
typename DataType>
119 return { lhs.x - rhs.x, lhs.y - rhs.y };
122template <
typename DataType>
126 return { lhs.x * rhs.x, lhs.y * rhs.y };
129template <
typename DataType>
133 return { lhs.x / rhs.x, lhs.y / rhs.y };
136template <
typename DataType,
typename ScaleType>
139 return {
static_cast<DataType
>(lhs.x * rhs),
140 static_cast<DataType
>(lhs.y * rhs) };
143template <
typename DataType,
typename ScaleType>
146 return {
static_cast<DataType
>(lhs * rhs.x),
147 static_cast<DataType
>(lhs * rhs.y) };
150template <
typename DataType,
typename ScaleType>
153 return {
static_cast<DataType
>(lhs.x / rhs),
154 static_cast<DataType
>(lhs.y / rhs) };
158template <
typename DataType>
161 return lhs.x * rhs.x + lhs.y * rhs.y;
165template <
typename DataType>
172template <
typename DataType>
179template <
typename DataType>
184 if (
norm <= std::numeric_limits<DataType>::epsilon())
bool operator==(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
PointType< DataType > operator*(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
PointType< DataType > operator+(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
PointType< To > point_cast(PointType< From > point)
Casts a point to another point type.
auto DotProduct(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
Returns the dot (inner) product between the vectors, defined by points.
PointType< DataType > operator/(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
auto Norm(PointType< DataType > lhs) noexcept
Returns the length of a vector matching the point.
auto Distance(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
Returns the distance between the two points.
bool operator!=(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
PointType< DataType > operator-(PointType< DataType > lhs, PointType< DataType > rhs) noexcept
auto Normalized(PointType< DataType > pt) noexcept
Returns a normalized vector in the direction of point.
__m128 norm(__m128 x, __m128 y)
__finl float_x4 __vecc sqrt(const float_x4 &a)
PointType & operator-=(PointType rhs) noexcept
PointType & operator*=(PointType rhs) noexcept
PointType operator-() const noexcept
PointType & operator+=(PointType rhs) noexcept
PointType & operator/=(PointType rhs) noexcept
bool IsZero() const noexcept
PointType & operator/=(ScaleType scale) noexcept
PointType & operator*=(ScaleType scale) noexcept