18#ifndef INCLUDED_FIXED_VECTOR3D
19#define INCLUDED_FIXED_VECTOR3D
36 return (
X == v.
X &&
Y == v.
Y &&
Z == v.
Z);
42 return (
X != v.
X ||
Y != v.
Y ||
Z != v.
Z);
88 std::uint64_t t = xx + yy;
91 std::uint64_t d2 = t + zz;
139 CheckSignedSubtractionOverflow(std::int64_t, y_vz, z_vy, L
"Overflow in CFixedVector3D::Cross() part 1", L
"Underflow in CFixedVector3D::Cross() part 1")
140 std::int64_t x = y_vz - z_vy;
145 CheckSignedSubtractionOverflow(std::int64_t, z_vx, x_vz, L
"Overflow in CFixedVector3D::Cross() part 2", L
"Underflow in CFixedVector3D::Cross() part 2")
146 std::int64_t y = z_vx - x_vz;
151 CheckSignedSubtractionOverflow(std::int64_t, x_vy, y_vx, L
"Overflow in CFixedVector3D::Cross() part 3", L
"Underflow in CFixedVector3D::Cross() part 3")
152 std::int64_t z = x_vy - y_vx;
155 CheckCastOverflow(x, std::int32_t, L
"Overflow in CFixedVector3D::Cross() part 4", L
"Underflow in CFixedVector3D::Cross() part 4")
156 CheckCastOverflow(y, std::int32_t, L
"Overflow in CFixedVector3D::Cross() part 5", L
"Underflow in CFixedVector3D::Cross() part 5")
157 CheckCastOverflow(z, std::int32_t, L
"Overflow in CFixedVector3D::Cross() part 6", L
"Underflow in CFixedVector3D::Cross() part 6")
173 CheckSignedAdditionOverflow(std::int64_t, x, y, L
"Overflow in CFixedVector3D::Dot() part 1", L
"Underflow in CFixedVector3D::Dot() part 1")
174 std::int64_t t = x + y;
176 CheckSignedAdditionOverflow(std::int64_t, t, z, L
"Overflow in CFixedVector3D::Dot() part 2", L
"Underflow in CFixedVector3D::Dot() part 2")
177 std::int64_t sum = t + z;
179 CheckCastOverflow(sum, std::int32_t, L
"Overflow in CFixedVector3D::Dot() part 3", L
"Underflow in CFixedVector3D::Dot() part 3")
#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 CheckSignedSubtractionOverflow(type, left, right, overflowWarning, underflowWarning)
Definition: Fixed.h:67
#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: FixedVector3D.h:25
bool operator==(const CFixedVector3D &v) const
Vector equality.
Definition: FixedVector3D.h:34
fixed Dot(const CFixedVector3D &v)
Compute the dot product of this vector with another.
Definition: FixedVector3D.h:168
void Normalize(fixed n)
Normalize the vector so that length is close to n.
Definition: FixedVector3D.h:121
CFixedVector3D(fixed X, fixed Y, fixed Z)
Definition: FixedVector3D.h:31
CFixedVector3D operator-() const
Negation.
Definition: FixedVector3D.h:58
CFixedVector3D & operator+=(const CFixedVector3D &v)
Vector addition.
Definition: FixedVector3D.h:64
CFixedVector3D operator+(const CFixedVector3D &v) const
Vector addition.
Definition: FixedVector3D.h:46
fixed Y
Definition: FixedVector3D.h:27
bool operator!=(const CFixedVector3D &v) const
Vector inequality.
Definition: FixedVector3D.h:40
fixed Z
Definition: FixedVector3D.h:27
fixed X
Definition: FixedVector3D.h:27
CFixedVector3D & operator-=(const CFixedVector3D &v)
Vector subtraction.
Definition: FixedVector3D.h:71
CFixedVector3D Cross(const CFixedVector3D &v)
Compute the cross product of this vector with another.
Definition: FixedVector3D.h:135
void Normalize()
Normalize the vector so that length is close to 1.
Definition: FixedVector3D.h:106
fixed Length() const
Returns the length of the vector.
Definition: FixedVector3D.h:82
CFixedVector3D operator-(const CFixedVector3D &v) const
Vector subtraction.
Definition: FixedVector3D.h:52
CFixedVector3D()
Definition: FixedVector3D.h:29
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 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