18#ifndef INCLUDED_FIXED_VECTOR2D
19#define INCLUDED_FIXED_VECTOR2D
35 return (
X == v.
X &&
Y == v.
Y);
41 return (
X != v.
X ||
Y != v.
Y);
106 std::uint64_t d2 = xx + yy;
213 CheckSignedAdditionOverflow(std::int64_t, x, y, L
"Overflow in CFixedVector2D::Dot() part 1", L
"Underflow in CFixedVector2D::Dot() part 1")
214 std::int64_t sum = x + y;
217 CheckCastOverflow(sum, std::int32_t, L
"Overflow in CFixedVector2D::Dot() part 2", L
"Underflow in CFixedVector2D::Dot() part 2")
230 return x > -y ? 1 : x < -y ? -1 : 0;
void sincos_approx(CFixed_15_16 a, CFixed_15_16 &sin_out, CFixed_15_16 &cos_out)
Compute sin(a) and cos(a).
Definition: Fixed.cpp:189
#define SQUARE_U64_FIXED(a)
Definition: Fixed.h:47
#define MUL_I64_I32_I32(a, b)
Definition: Fixed.h:45
#define CheckCastOverflow(var, targetType, overflowWarning, underflowWarning)
Definition: Fixed.h:79
#define CheckSignedAdditionOverflow(type, left, right, overflowWarning, underflowWarning)
Definition: Fixed.h:73
#define CheckUnsignedAdditionOverflow(result, operand, overflowWarning)
Definition: Fixed.h:89
#define CheckU32CastOverflow(var, targetType, overflowWarning)
Definition: Fixed.h:85
std::uint32_t isqrt64(std::uint64_t n)
64-bit integer square root.
Definition: Sqrt.cpp:23
Definition: FixedVector2D.h:25
fixed X
Definition: FixedVector2D.h:27
CFixedVector2D operator+(const CFixedVector2D &v) const
Vector addition.
Definition: FixedVector2D.h:45
int RelativeOrientation(const CFixedVector2D &v) const
Definition: FixedVector2D.h:226
CFixedVector2D & operator-=(const CFixedVector2D &v)
Vector subtraction.
Definition: FixedVector2D.h:70
void Normalize(fixed n)
Normalize the vector so that length is close to n.
Definition: FixedVector2D.h:195
CFixedVector2D operator-() const
Negation.
Definition: FixedVector2D.h:57
int CompareLength(fixed cmp) const
Returns -1, 0, +1 depending on whether length is less/equal/greater than the argument.
Definition: FixedVector2D.h:122
fixed Dot(const CFixedVector2D &v) const
Compute the dot product of this vector with another.
Definition: FixedVector2D.h:209
int CompareLength(const CFixedVector2D &other) const
Returns -1, 0, +1 depending on whether length is less/equal/greater than the argument's length.
Definition: FixedVector2D.h:158
CFixedVector2D operator*(int n) const
Scalar multiplication by an integer.
Definition: FixedVector2D.h:77
CFixedVector2D Multiply(fixed n) const
Multiply by a CFixed.
Definition: FixedVector2D.h:92
bool operator!=(const CFixedVector2D &v) const
Vector inequality.
Definition: FixedVector2D.h:39
CFixedVector2D Perpendicular() const
Definition: FixedVector2D.h:233
CFixedVector2D Rotate(fixed angle) const
Rotate the vector by the given angle (anticlockwise).
Definition: FixedVector2D.h:241
fixed Length() const
Returns the length of the vector.
Definition: FixedVector2D.h:101
fixed Y
Definition: FixedVector2D.h:27
CFixedVector2D()
Definition: FixedVector2D.h:29
CFixedVector2D(fixed X, fixed Y)
Definition: FixedVector2D.h:30
CFixedVector2D operator/(int n) const
Scalar division by an integer. Must not have n == 0.
Definition: FixedVector2D.h:83
bool IsZero() const
Definition: FixedVector2D.h:172
CFixedVector2D & operator+=(const CFixedVector2D &v)
Vector addition.
Definition: FixedVector2D.h:63
bool operator==(const CFixedVector2D &v) const
Vector equality.
Definition: FixedVector2D.h:33
void Normalize()
Normalize the vector so that length is close to 1.
Definition: FixedVector2D.h:181
int CompareLengthSquared(std::uint64_t cmpSquared) const
Same as above, but avoids squaring the compared value.
Definition: FixedVector2D.h:140
CFixedVector2D operator-(const CFixedVector2D &v) const
Vector subtraction.
Definition: FixedVector2D.h:51
A simple fixed-point number class.
Definition: Fixed.h:129
void SetInternalValue(T n)
Definition: Fixed.h:145
@ fract_bits
Definition: Fixed.h:136
CFixed Multiply(CFixed n) const
Multiply by a CFixed.
Definition: Fixed.h:331
CFixed MulDiv(CFixed m, CFixed d) const
Compute this*m/d.
Definition: Fixed.h:351
constexpr bool IsZero() const
Returns true if the number is precisely 0.
Definition: Fixed.h:218
T GetInternalValue() const
Definition: Fixed.h:144