9 #ifndef _TurtleBrains_Vector_h_
10 #define _TurtleBrains_Vector_h_
13 #include "../core/tb_error.h"
14 #include "../core/tb_defines.h"
59 #if defined(tb_visual_cpp)
61 #pragma warning(disable: 4201)
62 struct {
float x, y; };
65 struct {
float x, y; };
95 inline Vector2(
const float valueX,
const float valueY) :
146 return (
true ==
IsEqual(x, other.x) &&
true ==
IsEqual(y, other.y)) ?
true :
false;
155 return (
true ==
operator==(other)) ?
false :
true;
161 inline operator const float*(void)
const {
return mComponents; }
167 inline operator float*(void) {
return mComponents; }
172 inline const float&
operator[](
const size_t index)
const {
return mComponents[index]; }
178 inline float&
operator[](
const size_t index) {
return mComponents[index]; }
180 #ifndef tb_math_less_operators
244 inline float Magnitude(
void)
const {
return sqrt((x * x) + (y * y)); }
259 if (
true ==
IsZero(magnitude)) {
return Zero(); }
260 return Vector2(x / magnitude, y / magnitude);
271 if (
false ==
IsZero(magnitude))
282 inline void Scale(
float scalar) { *
this *= scalar; }
313 float mComponents[3];
315 #if defined(tb_visual_cpp)
316 #pragma warning(push)
317 #pragma warning(disable: 4201)
318 struct {
float x, y, z; };
321 struct {
float x, y, z; };
353 inline Vector3(
const float valueX,
const float valueY,
const float valueZ) :
429 return (
true ==
IsEqual(x, other.x) &&
true ==
IsEqual(y, other.y) &&
true ==
IsEqual(z, other.z)) ?
true :
false;
438 return (
true ==
operator==(other)) ?
false :
true;
444 inline operator const float*(void)
const {
return mComponents; }
450 inline operator float*(void) {
return mComponents; }
455 inline const float&
operator[](
const size_t index)
const {
return mComponents[index]; }
461 inline float&
operator[](
const size_t index) {
return mComponents[index]; }
466 #ifndef tb_math_less_operators
504 inline Vector3&
operator*=(
float scalar) { x *= scalar; y *= scalar; z *= scalar;
return *
this; }
515 inline Vector3&
operator/=(
float scalar) { x /= scalar; y /= scalar; z /= scalar;
return *
this; }
526 inline float operator*(
const Vector3 &rhs)
const {
return (x * rhs.x) + (y * rhs.y) + (z * rhs.z); }
534 return Vector3((y * rightSide.z) - (rightSide.y * z), -((x * rightSide.z) - (rightSide.x * z)), (x * rightSide.y) - (rightSide.x * y));
542 inline float Magnitude(
void)
const {
return sqrt((x * x) + (y * y) + (z * z)); }
557 if (
true ==
IsZero(magnitude)) {
return Zero(); }
558 return Vector3(x / magnitude, y / magnitude, z / magnitude);
569 if (
false ==
IsZero(magnitude))
581 inline void Scale(
float scalar) { *
this *= scalar; }
612 float mComponents[4];
614 #if defined(tb_visual_cpp)
615 #pragma warning(push)
616 #pragma warning(disable: 4201)
617 struct {
float x, y, z, w; };
620 struct {
float x, y, z, w; };
654 inline Vector4(
const float valueX,
const float valueY,
const float valueZ,
const float valueW) :
669 inline explicit Vector4(
const Vector2& other,
const float valueZ,
const float valueW) :
740 return (
true ==
IsEqual(x, other.x) &&
true ==
IsEqual(y, other.y) &&
741 true ==
IsEqual(z, other.z) &&
true ==
IsEqual(w, other.w)) ?
true :
false;
750 return (
true ==
operator==(other)) ?
false :
true;
756 inline operator const float*(void)
const {
return mComponents; }
762 inline operator float*(void) {
return mComponents; }
767 inline const float&
operator[](
const size_t index)
const {
return mComponents[index]; }
773 inline float&
operator[](
const size_t index) {
return mComponents[index]; }
779 #ifndef tb_math_less_operators
789 inline Vector4&
operator+=(
const Vector4& rightSide) { x += rightSide.x, y += rightSide.y; z += rightSide.z; w += rightSide.w;
return *
this; }
799 inline Vector4&
operator-=(
const Vector4& rightSide) { x -= rightSide.x, y -= rightSide.y; z -= rightSide.z; w -= rightSide.w;
return *
this; }
811 friend Vector4 operator*(
float scalar,
const Vector4& rightSide) {
return Vector4(scalar * rightSide.x, scalar * rightSide.y, scalar * rightSide.z, scalar * rightSide.w); }
817 inline Vector4&
operator*=(
float scalar) { x *= scalar; y *= scalar; z *= scalar; w *= scalar;
return *
this; }
828 inline Vector4&
operator/=(
float scalar) { x /= scalar; y /= scalar; z /= scalar; w /= scalar;
return *
this; }
839 inline float operator*(
const Vector4& rightSide)
const {
return (x * rightSide.x) + (y * rightSide.y) + (z * rightSide.z) + (w * rightSide.w); }
848 inline float Magnitude(
void)
const {
return sqrt((x * x) + (y * y) + (z * z) + (w * w)); }
854 inline float MagnitudeSquared(
void)
const {
return (x * x) + (y * y) + (z * z) + (w * w); }
863 if (
true ==
IsZero(magnitude)) {
return Zero(); }
864 return Vector4(x / magnitude, y / magnitude, z / magnitude, w / magnitude);
875 if (
false ==
IsZero(magnitude))
888 inline void Scale(
float scalar) { *
this *= scalar; }
917 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
918 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
919 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
921 result->x = leftSide->x + rightSide->x;
922 result->y = leftSide->y + rightSide->y;
931 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
932 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
933 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
935 result->x = leftSide->x + rightSide->x;
936 result->y = leftSide->y + rightSide->y;
937 result->z = leftSide->z + rightSide->z;
946 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
947 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
948 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
950 result->x = leftSide->x + rightSide->x;
951 result->y = leftSide->y + rightSide->y;
952 result->z = leftSide->z + rightSide->z;
953 result->w = leftSide->w + rightSide->w;
969 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
970 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
971 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
973 result->x = leftSide->x - rightSide->x;
974 result->y = leftSide->y - rightSide->y;
983 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
984 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
985 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
987 result->x = leftSide->x - rightSide->x;
988 result->y = leftSide->y - rightSide->y;
989 result->z = leftSide->z - rightSide->z;
998 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
999 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
1000 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
1002 result->x = leftSide->x - rightSide->x;
1003 result->y = leftSide->y - rightSide->y;
1004 result->z = leftSide->z - rightSide->z;
1005 result->w = leftSide->w - rightSide->w;
1020 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1021 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1023 result->x = input->x * scalar;
1024 result->y = input->y * scalar;
1033 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1034 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1036 result->x = input->x * scalar;
1037 result->y = input->y * scalar;
1038 result->z = input->z * scalar;
1047 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1048 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1050 result->x = input->x * scalar;
1051 result->y = input->y * scalar;
1052 result->z = input->z * scalar;
1053 result->w = input->w * scalar;
1068 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1069 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1071 result->x = input->x / scalar;
1072 result->y = input->y / 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;
1095 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1096 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1098 result->x = input->x / scalar;
1099 result->y = input->y / scalar;
1100 result->z = input->z / scalar;
1101 result->w = input->w / 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;
1119 result->y = -input->y;
1128 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1129 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1131 result->x = -input->x;
1132 result->y = -input->y;
1133 result->z = -input->z;
1142 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1143 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1145 result->x = -input->x;
1146 result->y = -input->y;
1147 result->z = -input->z;
1148 result->w = -input->w;
1162 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
1163 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
1164 return (leftSide->x * rightSide->x) + (leftSide->y * rightSide->y);
1172 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
1173 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
1174 return (leftSide->x * rightSide->x) + (leftSide->y * rightSide->y) + (leftSide->z * rightSide->z);
1182 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
1183 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
1184 return (leftSide->x * rightSide->x) + (leftSide->y * rightSide->y) + (leftSide->z * rightSide->z) + (leftSide->w * rightSide->w);
1202 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1203 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
1204 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
1205 tb_error_if(leftSide == rightSide,
"tbExternalError: Invalid parameter; expected leftSide to be different from rightSide.");
1206 tb_error_if(result == leftSide || result == rightSide,
"Invalid parameter; expected result to be different than leftSide and rightSide");
1208 result->x = ((leftSide->y * rightSide->z) - (rightSide->y * leftSide->z));
1209 result->y = -(((leftSide->x * rightSide->z) - (rightSide->x * leftSide->z)));
1210 result->z = ((leftSide->x * rightSide->y) - (rightSide->x * leftSide->y));
1220 tb_error_if(
nullptr == result,
"tbExternalError: Invalid parameter for result, expected valid pointer.");
1221 tb_error_if(
nullptr == leftSide,
"tbExternalError: Invalid parameter for leftSide, expected valid pointer.");
1222 tb_error_if(
nullptr == rightSide,
"tbExternalError: Invalid parameter for rightSide, expected valid pointer.");
1223 tb_error_if(result == leftSide || result == rightSide,
"Invalid parameter; expected result to be different than leftSide and rightSide");
1225 tb_error_if(
true,
"Not sure if this is an accurate Vector4 CrossProduct");
1226 result->x = ((leftSide->y * rightSide->z) - (rightSide->y * leftSide->z));
1227 result->y = -(((leftSide->x * rightSide->z) - (rightSide->x * leftSide->z)));
1228 result->z = ((leftSide->x * rightSide->y) - (rightSide->x * leftSide->y));
1242 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1243 return sqrt((input->x * input->x) + (input->y * input->y));
1251 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1252 return sqrt((input->x * input->x) + (input->y * input->y) + (input->z * input->z));
1260 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1261 return sqrt((input->x * input->x) + (input->y * input->y) + (input->z * input->z) + (input->w * input->w));
1274 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1275 return (input->x * input->x) + (input->y * input->y);
1283 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1284 return (input->x * input->x) + (input->y * input->y) + (input->z * input->z);
1292 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1293 return (input->x * input->x) + (input->y * input->y) + (input->z * input->z) + (input->w * input->w);
1306 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1309 if (
true ==
IsZero(magnitude))
1316 result->x = input->x / magnitude;
1317 result->y = input->y / magnitude;
1328 if (
true ==
IsZero(magnitude))
1336 result->x = input->x / magnitude;
1337 result->y = input->y / magnitude;
1338 result->z = input->z / magnitude;
1349 if (
true ==
IsZero(magnitude))
1358 result->x = input->x / magnitude;
1359 result->y = input->y / magnitude;
1360 result->z = input->z / magnitude;
1361 result->w = input->w / magnitude;
1378 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1381 if (
true ==
IsZero(magnitude))
1388 result->x = input->x / magnitude;
1389 result->y = input->y / magnitude;
1399 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1402 if (
true ==
IsZero(magnitude))
1410 result->x = input->x / magnitude;
1411 result->y = input->y / magnitude;
1412 result->z = input->z / magnitude;
1422 tb_error_if(
nullptr == input,
"tbExternalError: Invalid parameter for input, expected valid pointer.");
1425 if (
true ==
IsZero(magnitude))
1434 result->x = input->x / magnitude;
1435 result->y = input->y / magnitude;
1436 result->z = input->z / magnitude;
1437 result->w = input->w / magnitude;
1449 if (
true ==
IsZero(productOfMagnitudes)) {
return 0.0f; }
1451 const float clampedValue((value < -1.0f) ? -1.0f : (value > 1.0f) ? 1.0f : value);
1452 return acos(clampedValue);
1461 result->x = sin(orientation);
1463 result->z = -cos(orientation);
1474 result.x = sin(orientation);
1475 result.y = -cos(orientation);
1490 Vector3 vZAxis(0.0f, 0.0f, -1.0f);
1491 float orientation = acos((vZAxis.x * forward.x) + (vZAxis.y * forward.y) + (vZAxis.z * forward.z));
1492 if (forward.x < 0.0f)
1494 orientation = fabs(orientation -
kTwoPi);
1511 float orientation = acos((yAxis.x * forward.x) + (yAxis.y * forward.y));
1512 if (forward.x < 0.0f)
1514 orientation = fabs(orientation -
kTwoPi);
Vector2 * Vector2NormalizeMagnitude(Vector2 *result, const Vector2 *input, float &magnitude)
Definition: tb_vector.h:1376
Definition: tb_vector.h:47
Vector4(const Vector2 &other, const float valueZ, const float valueW)
Definition: tb_vector.h:669
const float & operator[](const size_t index) const
Definition: tb_vector.h:767
Vector3 operator-(void) const
Definition: tb_vector.h:521
Vector4 * Vector4Negate(Vector4 *result, const Vector4 *input)
Definition: tb_vector.h:1140
friend Vector4 operator*(float scalar, const Vector4 &rightSide)
Definition: tb_vector.h:811
Vector4(const float valueX, const float valueY, const float valueZ, const float valueW)
Definition: tb_vector.h:654
float & operator[](const size_t index)
Definition: tb_vector.h:461
Vector2 GetNormalized(void) const
Definition: tb_vector.h:256
Vector3(const SkipInitialization &fastAndStupid)
Definition: tb_vector.h:331
bool operator!=(const Vector2 &other) const
Definition: tb_vector.h:153
Vector2 operator*(float scalar) const
Definition: tb_vector.h:205
static Vector3 * OrientationToForwardVector3(Vector3 *result, float orientation)
Definition: tb_vector.h:1459
Vector4 operator/(float scalar) const
Definition: tb_vector.h:822
Vector4(const SkipInitialization &fastAndStupid)
Definition: tb_vector.h:630
Contains objects and functions for dealing with Vector and Matrix math.
float Vector4DotProduct(const Vector4 *leftSide, const Vector4 *rightSide)
Definition: tb_vector.h:1180
Vector3 & operator=(const Vector3 &other)
Definition: tb_vector.h:398
float & operator[](const size_t index)
Definition: tb_vector.h:178
Vector2 & operator/=(float scalar)
Definition: tb_vector.h:228
bool operator==(const Vector3 &other) const
Definition: tb_vector.h:427
Vector3 operator^(const Vector3 &rightSide) const
Definition: tb_vector.h:532
static float ForwardVector2ToOrientation(const Vector2 &forward)
Definition: tb_vector.h:1508
float Normalize(void)
Definition: tb_vector.h:268
Vector4(const Vector3 &other, const float valueW)
Definition: tb_vector.h:683
Vector4 & operator/=(float scalar)
Definition: tb_vector.h:828
Vector4(const Vector4 &other)
Definition: tb_vector.h:697
float Vector4MagnitudeSquared(const Vector4 *input)
Definition: tb_vector.h:1290
Vector2(void)
Definition: tb_vector.h:83
Definition: tb_vector.h:39
Definition: tb_vector.h:303
float Normalize(void)
Definition: tb_vector.h:872
Vector4 * Vector4CrossProduct(Vector4 *result, const Vector4 *leftSide, const Vector4 *rightSide)
Definition: tb_vector.h:1218
Vector3(const Vector2 &other, const float valueZ)
Definition: tb_vector.h:366
Vector4 * Vector4Add(Vector4 *result, const Vector4 *leftSide, const Vector4 *rightSide)
Definition: tb_vector.h:944
Vector4 * Vector4Subtract(Vector4 *result, const Vector4 *leftSide, const Vector4 *rightSide)
Definition: tb_vector.h:996
bool operator==(const Vector2 &other) const
Definition: tb_vector.h:144
Vector2 * Vector2Subtract(Vector2 *result, const Vector2 *leftSide, const Vector2 *rightSide)
Definition: tb_vector.h:967
Vector3 GetNormalized(void) const
Definition: tb_vector.h:554
void SetLength(float length)
Definition: tb_vector.h:291
friend Vector3 operator*(float scalar, const Vector3 &rightSide)
Definition: tb_vector.h:498
float Magnitude(void) const
Definition: tb_vector.h:542
void Scale(float scalar)
Definition: tb_vector.h:282
Vector2 operator-(void) const
Definition: tb_vector.h:233
Contains all functions, classes and helpers related to game/application development written by Tim "B...
Definition: tb_application_dialog.h:21
Vector3(void)
Definition: tb_vector.h:339
Vector3 * Vector3Add(Vector3 *result, const Vector3 *leftSide, const Vector3 *rightSide)
Definition: tb_vector.h:929
static Vector2 Zero(void)
Definition: tb_vector.h:53
Vector3 * Vector3Scale(Vector3 *result, const Vector3 *input, const float scalar)
Definition: tb_vector.h:1031
#define tb_unused(parameter)
Definition: tb_defines.h:19
float Vector4Magnitude(const Vector4 *input)
Definition: tb_vector.h:1258
Vector3 operator+(const Vector3 &rightSide) const
Definition: tb_vector.h:470
static float ForwardVector3ToOrientation(const Vector3 &forward)
Definition: tb_vector.h:1488
Vector3 * Vector3Normalize(Vector3 *result, const Vector3 *input)
Definition: tb_vector.h:1325
Vector4 & operator*=(float scalar)
Definition: tb_vector.h:817
void Scale(float scalar)
Definition: tb_vector.h:581
Definition: tb_vector.h:40
VectorComponent
Definition: tb_vector.h:35
SkipInitialization
Definition: tb_vector.h:29
Vector3 * Vector3NormalizeMagnitude(Vector3 *result, const Vector3 *input, float &magnitude)
Definition: tb_vector.h:1397
bool operator!=(const Vector3 &other) const
Definition: tb_vector.h:436
float Magnitude(void) const
Definition: tb_vector.h:244
float Vector2Magnitude(const Vector2 *input)
Definition: tb_vector.h:1240
Vector2 * Vector2Negate(Vector2 *result, const Vector2 *input)
Definition: tb_vector.h:1113
static const float kTwoPi(kPi *2.0f)
A constant for Pi * 2 stored in a float.
Vector2 operator-(const Vector2 &rightSide) const
Definition: tb_vector.h:195
Vector4 & operator=(const Vector4 &other)
Definition: tb_vector.h:717
Vector2 operator+(const Vector2 &rightSide) const
Definition: tb_vector.h:184
Vector3 & operator-=(const Vector3 &rightSide)
Definition: tb_vector.h:486
Vector2 & operator=(const Vector2 &other)
Definition: tb_vector.h:125
float operator*(const Vector4 &rightSide) const
Definition: tb_vector.h:839
Vector2 & operator*=(float scalar)
Definition: tb_vector.h:217
float Magnitude(void) const
Definition: tb_vector.h:848
float operator*(const Vector3 &rhs) const
Definition: tb_vector.h:526
static Vector4 Zero(void)
Definition: tb_vector.h:608
Vector4 * Vector4Scale(Vector4 *result, const Vector4 *input, const float scalar)
Definition: tb_vector.h:1045
Vector4 * Vector4Normalize(Vector4 *result, const Vector4 *input)
Definition: tb_vector.h:1346
Vector3 * Vector3Subtract(Vector3 *result, const Vector3 *leftSide, const Vector3 *rightSide)
Definition: tb_vector.h:981
Vector2 * Vector2Add(Vector2 *result, const Vector2 *leftSide, const Vector2 *rightSide)
Definition: tb_vector.h:915
void Scale(float scalar)
Definition: tb_vector.h:888
bool operator!=(const Vector4 &other) const
Definition: tb_vector.h:748
Vector4 * Vector4NormalizeMag(Vector4 *result, const Vector4 *input, float &magnitude)
Definition: tb_vector.h:1420
const float & operator[](const size_t index) const
Definition: tb_vector.h:455
static Vector2 & OrientationToForwardVector2(Vector2 &result, float orientation)
Definition: tb_vector.h:1472
~Vector4(void)
Definition: tb_vector.h:708
Vector2 * Vector2Normalize(Vector2 *result, const Vector2 *input)
Definition: tb_vector.h:1304
~Vector3(void)
Definition: tb_vector.h:389
float MagnitudeSquared(void) const
Definition: tb_vector.h:854
float Vector3AngleBetween(const Vector3 *left, const Vector3 *right)
Definition: tb_vector.h:1446
float Vector2MagnitudeSquared(const Vector2 *input)
Definition: tb_vector.h:1272
Vector2 operator/(float scalar) const
Definition: tb_vector.h:222
void SetLength(float length)
Definition: tb_vector.h:897
float & operator[](const size_t index)
Definition: tb_vector.h:773
float Normalize(void)
Definition: tb_vector.h:566
float MagnitudeSquared(void) const
Definition: tb_vector.h:250
float Vector3DotProduct(const Vector3 *leftSide, const Vector3 *rightSide)
Definition: tb_vector.h:1170
Vector2(const SkipInitialization &fastAndStupid)
Definition: tb_vector.h:75
Vector4 GetNormalized(void) const
Definition: tb_vector.h:860
Vector4 operator+(const Vector4 &rightSide) const
Definition: tb_vector.h:783
Vector3 * Vector3ScaleDivide(Vector3 *result, const Vector3 *input, const float scalar)
Definition: tb_vector.h:1079
bool IsZero(const float value, const float tolerance=tbMath::kTolerance)
Definition: tb_math.h:42
Vector2(const Vector2 &other)
Definition: tb_vector.h:107
Vector2(const float valueX, const float valueY)
Definition: tb_vector.h:95
Vector2 * Vector2ScaleDivide(Vector2 *result, const Vector2 *input, const float scalar)
Definition: tb_vector.h:1066
bool IsEqual(const float leftValue, const float rightValue, const float tolerance=tbMath::kTolerance)
Definition: tb_math.h:29
Vector3(const float valueX, const float valueY, const float valueZ)
Definition: tb_vector.h:353
Vector3 * Vector3CrossProduct(Vector3 *result, const Vector3 *leftSide, const Vector3 *rightSide)
Definition: tb_vector.h:1200
friend Vector2 operator*(float scalar, const Vector2 &rightSide)
Definition: tb_vector.h:211
float MagnitudeSquared(void) const
Definition: tb_vector.h:548
float Vector2DotProduct(const Vector2 *leftSide, const Vector2 *rightSide)
Definition: tb_vector.h:1160
Vector4 * Vector4ScaleDivide(Vector4 *result, const Vector4 *input, const float scalar)
Definition: tb_vector.h:1093
const float & operator[](const size_t index) const
Definition: tb_vector.h:172
Vector4 operator*(float scalar) const
Definition: tb_vector.h:805
Vector2 & operator+=(const Vector2 &rightSide)
Definition: tb_vector.h:190
Definition: tb_vector.h:38
bool operator==(const Vector4 &other) const
Definition: tb_vector.h:738
~Vector2(void)
Definition: tb_vector.h:116
Vector4 & operator+=(const Vector4 &rightSide)
Definition: tb_vector.h:789
void SetLength(float length)
Definition: tb_vector.h:590
Vector4(void)
Definition: tb_vector.h:638
float Vector3MagnitudeSquared(const Vector3 *input)
Definition: tb_vector.h:1281
Vector3 & operator/=(float scalar)
Definition: tb_vector.h:515
Definition: tb_vector.h:37
Vector3 & operator*=(float scalar)
Definition: tb_vector.h:504
Vector3 operator-(const Vector3 &rightSide) const
Definition: tb_vector.h:481
Vector3(const Vector3 &other)
Definition: tb_vector.h:379
Vector4 operator-(const Vector4 &rightSide) const
Definition: tb_vector.h:794
#define tb_error_if(errorTest, message,...)
Definition: tb_error.h:37
static Vector3 Zero(void)
Definition: tb_vector.h:309
Vector3 operator*(float scalar) const
Definition: tb_vector.h:492
float operator*(const Vector2 &rhs) const
Definition: tb_vector.h:238
Vector4 & operator-=(const Vector4 &rightSide)
Definition: tb_vector.h:799
Vector3 * Vector3Negate(Vector3 *result, const Vector3 *input)
Definition: tb_vector.h:1126
Vector2 & operator-=(const Vector2 &rightSide)
Definition: tb_vector.h:200
Vector3 operator/(float scalar) const
Definition: tb_vector.h:509
Vector4 operator-(void) const
Definition: tb_vector.h:834
float Vector3Magnitude(const Vector3 *input)
Definition: tb_vector.h:1249
Definition: tb_vector.h:602
Vector3 & operator+=(const Vector3 &rightSide)
Definition: tb_vector.h:476
Vector2 * Vector2Scale(Vector2 *result, const Vector2 *input, const float scalar)
Definition: tb_vector.h:1018