|
@@ -15,6 +15,7 @@
|
|
* - Functions use always a "result" variable for return
|
|
* - Functions use always a "result" variable for return
|
|
* - Functions are always defined inline
|
|
* - Functions are always defined inline
|
|
* - Angles are always in radians (DEG2RAD/RAD2DEG macros provided for convenience)
|
|
* - Angles are always in radians (DEG2RAD/RAD2DEG macros provided for convenience)
|
|
|
|
+* - No compound literals used to make sure libray is compatible with C++
|
|
*
|
|
*
|
|
* CONFIGURATION:
|
|
* CONFIGURATION:
|
|
* #define RAYMATH_IMPLEMENTATION
|
|
* #define RAYMATH_IMPLEMENTATION
|
|
@@ -716,12 +717,16 @@ RMAPI Vector3 Vector3Normalize(Vector3 v)
|
|
//Calculate the projection of the vector v1 on to v2
|
|
//Calculate the projection of the vector v1 on to v2
|
|
RMAPI Vector3 Vector3Project(Vector3 v1, Vector3 v2)
|
|
RMAPI Vector3 Vector3Project(Vector3 v1, Vector3 v2)
|
|
{
|
|
{
|
|
|
|
+ Vector3 result = { 0 };
|
|
|
|
+
|
|
float v1dv2 = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
|
|
float v1dv2 = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
|
|
float v2dv2 = (v2.x*v2.x + v2.y*v2.y + v2.z*v2.z);
|
|
float v2dv2 = (v2.x*v2.x + v2.y*v2.y + v2.z*v2.z);
|
|
|
|
|
|
float mag = v1dv2/v2dv2;
|
|
float mag = v1dv2/v2dv2;
|
|
|
|
|
|
- Vector3 result = { v2.x*mag , v2.y*mag, v2.z*mag };
|
|
|
|
|
|
+ result.x = v2.x*mag;
|
|
|
|
+ result.y = v2.y*mag;
|
|
|
|
+ result.z = v2.z*mag;
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
@@ -729,12 +734,16 @@ RMAPI Vector3 Vector3Project(Vector3 v1, Vector3 v2)
|
|
//Calculate the rejection of the vector v1 on to v2
|
|
//Calculate the rejection of the vector v1 on to v2
|
|
RMAPI Vector3 Vector3Reject(Vector3 v1, Vector3 v2)
|
|
RMAPI Vector3 Vector3Reject(Vector3 v1, Vector3 v2)
|
|
{
|
|
{
|
|
|
|
+ Vector3 result = { 0 };
|
|
|
|
+
|
|
float v1dv2 = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
|
|
float v1dv2 = (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
|
|
float v2dv2 = (v2.x*v2.x + v2.y*v2.y + v2.z*v2.z);
|
|
float v2dv2 = (v2.x*v2.x + v2.y*v2.y + v2.z*v2.z);
|
|
|
|
|
|
float mag = v1dv2/v2dv2;
|
|
float mag = v1dv2/v2dv2;
|
|
|
|
|
|
- Vector3 result = { v1.x - (v2.x*mag) , v1.y - (v2.y*mag), v1.z - (v2.z*mag) };
|
|
|
|
|
|
+ result.x = v1.x - (v2.x*mag);
|
|
|
|
+ result.y = v1.y - (v2.y*mag);
|
|
|
|
+ result.z = v1.z - (v2.z*mag);
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|