9 #ifndef TurtleBrains_Vector_hpp
10 #define TurtleBrains_Vector_hpp
12 #include <turtle_brains/math/tb_math.hpp>
13 #include <turtle_brains/math/tb_angle.hpp>
14 #include <turtle_brains/core/tb_error.hpp>
15 #include <turtle_brains/core/tb_defines.hpp>
60 #if defined(tb_visual_cpp)
62 #pragma warning(disable: 4201)
63 struct {
float x, y; };
66 struct {
float x, y; };
96 inline Vector2(
const float valueX,
const float valueY) :
107 inline explicit Vector2(
const float* componentArray) :
108 x(componentArray[0]),
155 return (
true ==
IsEqual(x, other.x) &&
true ==
IsEqual(y, other.y)) ?
true :
false;
164 return (
true ==
operator==(other)) ?
false :
true;
170 inline explicit operator const float*(void)
const {
return mComponents; }
176 inline explicit operator float*(void) {
return mComponents; }
181 inline const float&
operator[](
const int index)
const {
return mComponents[index]; }
187 inline float&
operator[](
const int index) {
return mComponents[index]; }
189 #if defined(tb_with_math_operators)
190 inline Vector2 operator+(
const Vector2& rightSide)
const {
return Vector2(x + rightSide.x, y + rightSide.y); }
199 inline Vector2& operator+=(
const Vector2& rightSide) { x += rightSide.x; y += rightSide.y;
return *
this; }
204 inline Vector2 operator-(
const Vector2& rightSide)
const {
return Vector2(x - rightSide.x, y - rightSide.y); }
209 inline Vector2& operator-=(
const Vector2& rightSide) { x -= rightSide.x; y -= rightSide.y;
return *
this; }
214 inline Vector2 operator*(
float scalar)
const {
return Vector2(x * scalar, y * scalar); }
220 friend Vector2 operator*(
float scalar,
const Vector2& rightSide) {
return Vector2(scalar * rightSide.x, scalar * rightSide.y); }
226 inline Vector2& operator*=(
float scalar) { x *= scalar; y *= scalar;
return *
this; }
231 inline Vector2 operator/(
float scalar)
const {
return Vector2(x / scalar, y / scalar); }
237 inline Vector2& operator/=(
float scalar) { x /= scalar; y /= scalar;
return *
this; }
242 friend Vector2 operator/(
float scalar,
const Vector2& rightSide) {
return Vector2(scalar / rightSide.x, scalar / rightSide.y); }
252 inline float operator*(
const Vector2 &rhs)
const {
return (x * rhs.x) + (y * rhs.y); }
258 inline float Magnitude(
void)
const {
return sqrt((x * x) + (y * y)); }
264 inline float MagnitudeSquared(
void)
const {
return (x * x) + (y * y); }
270 inline Vector2 GetNormalized(
void)
const
272 const float magnitude(Magnitude());
273 if (
true ==
IsZero(magnitude)) {
return Zero(); }
274 return Vector2(x / magnitude, y / magnitude);
282 inline float Normalize(
void)
284 const float magnitude(Magnitude());
285 if (
false ==
IsZero(magnitude))
296 inline void Scale(
float scalar) { *
this *= scalar; }
305 inline void SetLength(
float length) { Normalize(); *
this *= length; }
327 float mComponents[3];
329 #if defined(tb_visual_cpp)
330 #pragma warning(push)
331 #pragma warning(disable: 4201)
332 struct {
float x, y, z; };
335 struct {
float x, y, z; };
367 inline Vector3(
const float valueX,
const float valueY,
const float valueZ) :
392 inline explicit Vector3(
const float* componentArray) :
393 x(componentArray[0]),
394 y(componentArray[1]),
452 return (
true ==
IsEqual(x, other.x) &&
true ==
IsEqual(y, other.y) &&
true ==
IsEqual(z, other.z)) ?
true :
false;
461 return (
true ==
operator==(other)) ?
false :
true;
467 inline explicit operator const float*(void)
const {
return mComponents; }
473 inline explicit operator float*(void) {
return mComponents; }
478 inline const float&
operator[](
const int index)
const {
return mComponents[index]; }
484 inline float&
operator[](
const int index) {
return mComponents[index]; }
486 #if defined(tb_with_math_operators)
487 inline Vector3 operator+(
const Vector3& rightSide)
const {
return Vector3(x + rightSide.x, y + rightSide.y, z + rightSide.z); }
496 inline Vector3& operator+=(
const Vector3& rightSide) { x += rightSide.x; y += rightSide.y; z += rightSide.z;
return *
this; }
501 inline Vector3 operator-(
const Vector3& rightSide)
const {
return Vector3(x - rightSide.x, y - rightSide.y, z - rightSide.z); }
506 inline Vector3& operator-=(
const Vector3& rightSide) { x -= rightSide.x; y -= rightSide.y; z -= rightSide.z;
return *
this; }
512 inline Vector3 operator*(
float scalar)
const {
return Vector3(x * scalar, y * scalar, z * scalar); }
518 friend Vector3 operator*(
float scalar,
const Vector3& rightSide) {
return Vector3(scalar * rightSide.x, scalar * rightSide.y, scalar * rightSide.z); }
524 inline Vector3& operator*=(
float scalar) { x *= scalar; y *= scalar; z *= scalar;
return *
this; }
529 inline Vector3 operator/(
float scalar)
const {
return Vector3(x / scalar, y / scalar, z / scalar); }
535 inline Vector3& operator/=(
float scalar) { x /= scalar; y /= scalar; z /= scalar;
return *
this; }
540 friend Vector3 operator/(
float scalar,
const Vector3& rightSide) {
return Vector3(scalar / rightSide.x, scalar / rightSide.y, scalar / rightSide.z); }
545 inline Vector3 operator-(
void)
const {
return Vector3(-x, -y, -z); }
550 inline float operator*(
const Vector3 &rhs)
const {
return (x * rhs.x) + (y * rhs.y) + (z * rhs.z); }
558 return Vector3((y * rightSide.z) - (rightSide.y * z), -((x * rightSide.z) - (rightSide.x * z)), (x * rightSide.y) - (rightSide.x * y));
566 inline float Magnitude(
void)
const {
return sqrt((x * x) + (y * y) + (z * z)); }
572 inline float MagnitudeSquared(
void)
const {
return (x * x) + (y * y) + (z * z); }
578 inline Vector3 GetNormalized(
void)
const
580 const float magnitude(Magnitude());
581 if (
true ==
IsZero(magnitude)) {
return Zero(); }
582 return Vector3(x / magnitude, y / magnitude, z / magnitude);
590 inline float Normalize(
void)
592 const float magnitude(Magnitude());
593 if (
false ==
IsZero(magnitude))
605 inline void Scale(
float scalar) { *
this *= scalar; }
614 inline void SetLength(
float length) { Normalize(); *
this *= length; }
636 float mComponents[4];
638 #if defined(tb_visual_cpp)
639 #pragma warning(push)
640 #pragma warning(disable: 4201)
641 struct {
float x, y, z, w; };
644 struct {
float x, y, z, w; };
678 inline Vector4(
const float valueX,
const float valueY,
const float valueZ,
const float valueW) :
693 inline explicit Vector4(
const Vector2& other,
const float valueZ,
const float valueW) :
720 inline explicit Vector4(
const float* componentArray) :
721 x(componentArray[0]),
722 y(componentArray[1]),
723 z(componentArray[2]),
774 return (
true ==
IsEqual(x, other.x) &&
true ==
IsEqual(y, other.y) &&
775 true ==
IsEqual(z, other.z) &&
true ==
IsEqual(w, other.w)) ?
true :
false;
784 return (
true ==
operator==(other)) ?
false :
true;
790 inline explicit operator const float*(void)
const {
return mComponents; }
796 inline explicit operator float*(void) {
return mComponents; }
801 inline const float&
operator[](
const int index)
const {
return mComponents[index]; }
807 inline float&
operator[](
const int index) {
return mComponents[index]; }
809 #if defined(tb_with_math_operators)
810 inline Vector4 operator+(
const Vector4& rightSide)
const {
return Vector4(x + rightSide.x, y + rightSide.y, z + rightSide.z, w + rightSide.w); }
819 inline Vector4& operator+=(
const Vector4& rightSide) { x += rightSide.x; y += rightSide.y; z += rightSide.z; w += rightSide.w;
return *
this; }
824 inline Vector4 operator-(
const Vector4& rightSide)
const {
return Vector4(x - rightSide.x, y - rightSide.y, z - rightSide.z, w - rightSide.w); }
829 inline Vector4& operator-=(
const Vector4& rightSide) { x -= rightSide.x; y -= rightSide.y; z -= rightSide.z; w -= rightSide.w;
return *
this; }
835 inline Vector4 operator*(
float scalar)
const {
return Vector4(x * scalar, y * scalar, z * scalar, w * scalar); }
841 friend Vector4 operator*(
float scalar,
const Vector4& rightSide) {
return Vector4(scalar * rightSide.x, scalar * rightSide.y, scalar * rightSide.z, scalar * rightSide.w); }
847 inline Vector4& operator*=(
float scalar) { x *= scalar; y *= scalar; z *= scalar; w *= scalar;
return *
this; }
852 inline Vector4 operator/(
float scalar)
const {
return Vector4(x / scalar, y / scalar, z / scalar, w / scalar); }
858 inline Vector4& operator/=(
float scalar) { x /= scalar; y /= scalar; z /= scalar; w /= scalar;
return *
this; }
863 friend Vector4 operator/(
float scalar,
const Vector4& rightSide) {
return Vector4(scalar / rightSide.x, scalar / rightSide.y, scalar / rightSide.z, scalar / rightSide.w); }
868 inline Vector4 operator-(
void)
const {
return Vector4(-x, -y, -z, -w); }
873 inline float operator*(
const Vector4& rightSide)
const {
return (x * rightSide.x) + (y * rightSide.y) + (z * rightSide.z) + (w * rightSide.w); }
882 inline float Magnitude(
void)
const {
return sqrt((x * x) + (y * y) + (z * z) + (w * w)); }
888 inline float MagnitudeSquared(
void)
const {
return (x * x) + (y * y) + (z * z) + (w * w); }
894 inline Vector4 GetNormalized(
void)
const
896 const float magnitude(Magnitude());
897 if (
true ==
IsZero(magnitude)) {
return Zero(); }
898 return Vector4(x / magnitude, y / magnitude, z / magnitude, w / magnitude);
906 inline float Normalize(
void)
908 const float magnitude(Magnitude());
909 if (
false ==
IsZero(magnitude))
922 inline void Scale(
float scalar) { *
this *= scalar; }
931 inline void SetLength(
float length) { Normalize(); *
this *= length; }
951 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
952 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
953 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
955 result->x = leftSide->x + rightSide->x;
956 result->y = leftSide->y + rightSide->y;
965 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
966 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
967 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
969 result->x = leftSide->x + rightSide->x;
970 result->y = leftSide->y + rightSide->y;
971 result->z = leftSide->z + rightSide->z;
980 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
981 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
982 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
984 result->x = leftSide->x + rightSide->x;
985 result->y = leftSide->y + rightSide->y;
986 result->z = leftSide->z + rightSide->z;
987 result->w = leftSide->w + rightSide->w;
1003 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1004 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
1005 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
1007 result->x = leftSide->x - rightSide->x;
1008 result->y = leftSide->y - rightSide->y;
1017 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1018 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
1019 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
1021 result->x = leftSide->x - rightSide->x;
1022 result->y = leftSide->y - rightSide->y;
1023 result->z = leftSide->z - rightSide->z;
1032 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1033 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
1034 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
1036 result->x = leftSide->x - rightSide->x;
1037 result->y = leftSide->y - rightSide->y;
1038 result->z = leftSide->z - rightSide->z;
1039 result->w = leftSide->w - rightSide->w;
1054 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1055 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1057 result->x = input->x * scalar;
1058 result->y = input->y * scalar;
1067 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1068 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1070 result->x = input->x * scalar;
1071 result->y = input->y * scalar;
1072 result->z = input->z * scalar;
1081 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1082 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1084 result->x = input->x * scalar;
1085 result->y = input->y * scalar;
1086 result->z = input->z * scalar;
1087 result->w = input->w * scalar;
1102 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1103 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1105 result->x = input->x / scalar;
1106 result->y = input->y / scalar;
1115 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1116 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1118 result->x = input->x / scalar;
1119 result->y = input->y / scalar;
1120 result->z = input->z / scalar;
1129 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1130 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1132 result->x = input->x / scalar;
1133 result->y = input->y / scalar;
1134 result->z = input->z / scalar;
1135 result->w = input->w / scalar;
1149 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1150 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1152 result->x = -input->x;
1153 result->y = -input->y;
1162 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1163 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1165 result->x = -input->x;
1166 result->y = -input->y;
1167 result->z = -input->z;
1176 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1177 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1179 result->x = -input->x;
1180 result->y = -input->y;
1181 result->z = -input->z;
1182 result->w = -input->w;
1196 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
1197 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
1198 return (leftSide->x * rightSide->x) + (leftSide->y * rightSide->y);
1206 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
1207 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
1208 return (leftSide->x * rightSide->x) + (leftSide->y * rightSide->y) + (leftSide->z * rightSide->z);
1216 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
1217 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
1218 return (leftSide->x * rightSide->x) + (leftSide->y * rightSide->y) + (leftSide->z * rightSide->z) + (leftSide->w * rightSide->w);
1236 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1237 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
1238 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
1239 tb_error_if(leftSide == rightSide,
"tbExternalError: Invalid parameter; expected leftSide to be different from rightSide.");
1240 tb_error_if(result == leftSide || result == rightSide,
"Invalid parameter; expected result to be different than leftSide and rightSide");
1242 result->x = ((leftSide->y * rightSide->z) - (rightSide->y * leftSide->z));
1243 result->y = -(((leftSide->x * rightSide->z) - (rightSide->x * leftSide->z)));
1244 result->z = ((leftSide->x * rightSide->y) - (rightSide->x * leftSide->y));
1257 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1258 return sqrt((input->x * input->x) + (input->y * input->y));
1266 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1267 return sqrt((input->x * input->x) + (input->y * input->y) + (input->z * input->z));
1275 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1276 return sqrt((input->x * input->x) + (input->y * input->y) + (input->z * input->z) + (input->w * input->w));
1289 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1290 return (input->x * input->x) + (input->y * input->y);
1298 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1299 return (input->x * input->x) + (input->y * input->y) + (input->z * input->z);
1307 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1308 return (input->x * input->x) + (input->y * input->y) + (input->z * input->z) + (input->w * input->w);
1321 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1322 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1325 if (
true ==
IsZero(magnitude))
1332 result->x = input->x / magnitude;
1333 result->y = input->y / magnitude;
1343 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1344 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1347 if (
true ==
IsZero(magnitude))
1355 result->x = input->x / magnitude;
1356 result->y = input->y / magnitude;
1357 result->z = input->z / magnitude;
1367 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1368 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1371 if (
true ==
IsZero(magnitude))
1380 result->x = input->x / magnitude;
1381 result->y = input->y / magnitude;
1382 result->z = input->z / magnitude;
1383 result->w = input->w / magnitude;
1400 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1401 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1404 if (
true ==
IsZero(magnitude))
1411 result->x = input->x / magnitude;
1412 result->y = input->y / magnitude;
1422 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1423 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1426 if (
true ==
IsZero(magnitude))
1434 result->x = input->x / magnitude;
1435 result->y = input->y / magnitude;
1436 result->z = input->z / magnitude;
1446 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1447 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1450 if (
true ==
IsZero(magnitude))
1459 result->x = input->x / magnitude;
1460 result->y = input->y / magnitude;
1461 result->z = input->z / magnitude;
1462 result->w = input->w / magnitude;
1474 if (
true ==
IsZero(productOfMagnitudes)) {
return 0.0_radians; }
1476 const float clampedValue((value < -1.0f) ? -1.0f : (value > 1.0f) ? 1.0f : value);
1486 result.x = sin(orientation.
AsRadians());
1488 result.z = -cos(orientation.
AsRadians());
1498 result.x = sin(orientation.
AsRadians());
1499 result.y = -cos(orientation.
AsRadians());
1512 Vector3 vZAxis(0.0f, 0.0f, -1.0f);
1513 float orientation = acos((vZAxis.x * forward.x) + (vZAxis.y * forward.y) + (vZAxis.z * forward.z));
1514 if (forward.x < 0.0f)
1516 orientation = fabs(orientation -
kTwoPi);
1531 float orientation = acos((yAxis.x * forward.x) + (yAxis.y * forward.y));
1532 if (forward.x < 0.0f)
1534 orientation = fabs(orientation -
kTwoPi);
Vector2 * Vector2NormalizeMagnitude(Vector2 *result, const Vector2 *input, float &magnitude)
Definition: tb_vector.hpp:1398
Definition: tb_vector.hpp:48
Vector4(const Vector2 &other, const float valueZ, const float valueW)
Definition: tb_vector.hpp:693
Vector4 * Vector4Negate(Vector4 *result, const Vector4 *input)
Definition: tb_vector.hpp:1174
Vector4(const float valueX, const float valueY, const float valueZ, const float valueW)
Definition: tb_vector.hpp:678
Type AsRadians(void) const
Definition: tb_angle.hpp:79
Vector3(const SkipInitialization &fastAndStupid)
Definition: tb_vector.hpp:345
bool operator!=(const Vector2 &other) const
Definition: tb_vector.hpp:162
Angle Vector3AngleBetween(const Vector3 *left, const Vector3 *right)
Definition: tb_vector.hpp:1471
Vector4(const SkipInitialization &fastAndStupid)
Definition: tb_vector.hpp:654
Contains objects and functions for dealing with Vector and Matrix math.
float Vector4DotProduct(const Vector4 *leftSide, const Vector4 *rightSide)
Definition: tb_vector.hpp:1214
Vector3 & operator=(const Vector3 &other)
Definition: tb_vector.hpp:424
bool operator==(const Vector3 &other) const
Definition: tb_vector.hpp:450
float & operator[](const int index)
Definition: tb_vector.hpp:807
Vector4(const Vector3 &other, const float valueW)
Definition: tb_vector.hpp:707
Vector4(const Vector4 &other)
Definition: tb_vector.hpp:734
const float & operator[](const int index) const
Definition: tb_vector.hpp:801
Vector4(const float *componentArray)
Definition: tb_vector.hpp:720
float Vector4MagnitudeSquared(const Vector4 *input)
Definition: tb_vector.hpp:1305
Vector2(void)
Definition: tb_vector.hpp:84
Definition: tb_vector.hpp:40
Definition: tb_vector.hpp:317
static Vector2 & RotationToForwardVector2(Vector2 &result, const Angle &orientation)
Definition: tb_vector.hpp:1496
Vector3(const Vector2 &other, const float valueZ)
Definition: tb_vector.hpp:380
bool IsZero(const Type &value)
Definition: tb_math.hpp:53
Vector4 * Vector4Add(Vector4 *result, const Vector4 *leftSide, const Vector4 *rightSide)
Definition: tb_vector.hpp:978
Vector4 * Vector4Subtract(Vector4 *result, const Vector4 *leftSide, const Vector4 *rightSide)
Definition: tb_vector.hpp:1030
bool operator==(const Vector2 &other) const
Definition: tb_vector.hpp:153
Vector2 * Vector2Subtract(Vector2 *result, const Vector2 *leftSide, const Vector2 *rightSide)
Definition: tb_vector.hpp:1001
Here is some information about the primary namespace.
Definition: tb_application_dialog.hpp:21
Vector3(void)
Definition: tb_vector.hpp:353
Vector3 * Vector3Add(Vector3 *result, const Vector3 *leftSide, const Vector3 *rightSide)
Definition: tb_vector.hpp:963
static Vector2 Zero(void)
Definition: tb_vector.hpp:54
Vector3 * Vector3Scale(Vector3 *result, const Vector3 *input, const float scalar)
Definition: tb_vector.hpp:1065
#define tb_unused(parameter)
Definition: tb_defines.hpp:25
float Vector4Magnitude(const Vector4 *input)
Definition: tb_vector.hpp:1273
Vector3 * Vector3Normalize(Vector3 *result, const Vector3 *input)
Definition: tb_vector.hpp:1341
Definition: tb_vector.hpp:41
VectorComponent
Definition: tb_vector.hpp:36
SkipInitialization
Definition: tb_vector.hpp:30
Vector3 * Vector3NormalizeMagnitude(Vector3 *result, const Vector3 *input, float &magnitude)
Definition: tb_vector.hpp:1420
bool IsEqual(const Type &leftValue, const Type &rightValue)
Definition: tb_math.hpp:30
static Angle ForwardVector3ToRotationXZ(const Vector3 &forward)
Definition: tb_vector.hpp:1510
bool operator!=(const Vector3 &other) const
Definition: tb_vector.hpp:459
float Vector2Magnitude(const Vector2 *input)
Definition: tb_vector.hpp:1255
Vector2 * Vector2Negate(Vector2 *result, const Vector2 *input)
Definition: tb_vector.hpp:1147
static AngleType Radians(const Type angleInRadians)
Definition: tb_angle.hpp:48
Vector4 * Vector4NormalizeMagnitude(Vector4 *result, const Vector4 *input, float &magnitude)
Definition: tb_vector.hpp:1444
Vector4 & operator=(const Vector4 &other)
Definition: tb_vector.hpp:754
Vector2 & operator=(const Vector2 &other)
Definition: tb_vector.hpp:137
static Vector3 & RotationXZToForwardVector3(Vector3 &result, const Angle &orientation)
Definition: tb_vector.hpp:1484
static Vector4 Zero(void)
Definition: tb_vector.hpp:632
Vector4 * Vector4Scale(Vector4 *result, const Vector4 *input, const float scalar)
Definition: tb_vector.hpp:1079
Vector4 * Vector4Normalize(Vector4 *result, const Vector4 *input)
Definition: tb_vector.hpp:1365
Vector3 * Vector3Subtract(Vector3 *result, const Vector3 *leftSide, const Vector3 *rightSide)
Definition: tb_vector.hpp:1015
Vector2 * Vector2Add(Vector2 *result, const Vector2 *leftSide, const Vector2 *rightSide)
Definition: tb_vector.hpp:949
bool operator!=(const Vector4 &other) const
Definition: tb_vector.hpp:782
~Vector4(void)
Definition: tb_vector.hpp:745
Vector2 * Vector2Normalize(Vector2 *result, const Vector2 *input)
Definition: tb_vector.hpp:1319
~Vector3(void)
Definition: tb_vector.hpp:415
float Vector2MagnitudeSquared(const Vector2 *input)
Definition: tb_vector.hpp:1287
float Vector3DotProduct(const Vector3 *leftSide, const Vector3 *rightSide)
Definition: tb_vector.hpp:1204
Vector2(const SkipInitialization &fastAndStupid)
Definition: tb_vector.hpp:76
Vector3 * Vector3ScaleDivide(Vector3 *result, const Vector3 *input, const float scalar)
Definition: tb_vector.hpp:1113
Vector2(const Vector2 &other)
Definition: tb_vector.hpp:119
float & operator[](const int index)
Definition: tb_vector.hpp:187
Vector2(const float valueX, const float valueY)
Definition: tb_vector.hpp:96
Vector2 * Vector2ScaleDivide(Vector2 *result, const Vector2 *input, const float scalar)
Definition: tb_vector.hpp:1100
Vector3(const float valueX, const float valueY, const float valueZ)
Definition: tb_vector.hpp:367
Vector3 * Vector3CrossProduct(Vector3 *result, const Vector3 *leftSide, const Vector3 *rightSide)
Definition: tb_vector.hpp:1234
Vector3(const float *componentArray)
Definition: tb_vector.hpp:392
float Vector2DotProduct(const Vector2 *leftSide, const Vector2 *rightSide)
Definition: tb_vector.hpp:1194
Vector4 * Vector4ScaleDivide(Vector4 *result, const Vector4 *input, const float scalar)
Definition: tb_vector.hpp:1127
Definition: tb_vector.hpp:39
Definition: tb_angle.hpp:34
bool operator==(const Vector4 &other) const
Definition: tb_vector.hpp:772
float & operator[](const int index)
Definition: tb_vector.hpp:484
~Vector2(void)
Definition: tb_vector.hpp:128
Vector4(void)
Definition: tb_vector.hpp:662
float Vector3MagnitudeSquared(const Vector3 *input)
Definition: tb_vector.hpp:1296
Vector2(const float *componentArray)
Definition: tb_vector.hpp:107
Definition: tb_vector.hpp:38
Vector3(const Vector3 &other)
Definition: tb_vector.hpp:405
const float & operator[](const int index) const
Definition: tb_vector.hpp:478
static const float kTwoPi
A constant for Pi * 2 stored in a float.
Definition: tb_constants.hpp:20
static Angle ForwardVector2ToRotation(const Vector2 &forward)
Definition: tb_vector.hpp:1528
#define tb_error_if(errorTest, message,...)
Definition: tb_error.hpp:42
static Vector3 Zero(void)
Definition: tb_vector.hpp:323
const float & operator[](const int index) const
Definition: tb_vector.hpp:181
Vector3 * Vector3Negate(Vector3 *result, const Vector3 *input)
Definition: tb_vector.hpp:1160
float Vector3Magnitude(const Vector3 *input)
Definition: tb_vector.hpp:1264
Definition: tb_vector.hpp:626
Vector2 * Vector2Scale(Vector2 *result, const Vector2 *input, const float scalar)
Definition: tb_vector.hpp:1052