Make raymath naming and functions more consistent
This commit is contained in:
parent
b4af1b2cc0
commit
74f6e268b3
|
|
@ -1511,7 +1511,7 @@ Ray GetMouseRay(Vector2 mouse, Camera camera)
|
||||||
Vector3 cameraPlanePointerPos = rlUnproject((Vector3){ deviceCoords.x, deviceCoords.y, -1.0f }, matProj, matView);
|
Vector3 cameraPlanePointerPos = rlUnproject((Vector3){ deviceCoords.x, deviceCoords.y, -1.0f }, matProj, matView);
|
||||||
|
|
||||||
// Calculate normalized direction vector
|
// Calculate normalized direction vector
|
||||||
Vector3 direction = Vector3Normalize(Vector3Subtract(farPoint, nearPoint));
|
Vector3 direction = Vector3Normalize(Vector3SubtractV(farPoint, nearPoint));
|
||||||
|
|
||||||
if (camera.type == CAMERA_PERSPECTIVE) ray.position = camera.position;
|
if (camera.type == CAMERA_PERSPECTIVE) ray.position = camera.position;
|
||||||
else if (camera.type == CAMERA_ORTHOGRAPHIC) ray.position = cameraPlanePointerPos;
|
else if (camera.type == CAMERA_ORTHOGRAPHIC) ray.position = cameraPlanePointerPos;
|
||||||
|
|
|
||||||
46
src/models.c
46
src/models.c
|
|
@ -1111,8 +1111,8 @@ ModelAnimation *LoadModelAnimations(const char *filename, int *animCount)
|
||||||
{
|
{
|
||||||
animations[a].framePoses[frame][i].rotation = QuaternionMultiply(animations[a].framePoses[frame][animations[a].bones[i].parent].rotation, animations[a].framePoses[frame][i].rotation);
|
animations[a].framePoses[frame][i].rotation = QuaternionMultiply(animations[a].framePoses[frame][animations[a].bones[i].parent].rotation, animations[a].framePoses[frame][i].rotation);
|
||||||
animations[a].framePoses[frame][i].translation = Vector3RotateByQuaternion(animations[a].framePoses[frame][i].translation, animations[a].framePoses[frame][animations[a].bones[i].parent].rotation);
|
animations[a].framePoses[frame][i].translation = Vector3RotateByQuaternion(animations[a].framePoses[frame][i].translation, animations[a].framePoses[frame][animations[a].bones[i].parent].rotation);
|
||||||
animations[a].framePoses[frame][i].translation = Vector3Add(animations[a].framePoses[frame][i].translation, animations[a].framePoses[frame][animations[a].bones[i].parent].translation);
|
animations[a].framePoses[frame][i].translation = Vector3AddV(animations[a].framePoses[frame][i].translation, animations[a].framePoses[frame][animations[a].bones[i].parent].translation);
|
||||||
animations[a].framePoses[frame][i].scale = Vector3Multiply(animations[a].framePoses[frame][i].scale, animations[a].framePoses[frame][animations[a].bones[i].parent].scale);
|
animations[a].framePoses[frame][i].scale = Vector3MultiplyV(animations[a].framePoses[frame][i].scale, animations[a].framePoses[frame][animations[a].bones[i].parent].scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1165,10 +1165,10 @@ void UpdateModelAnimation(Model model, ModelAnimation anim, int frame)
|
||||||
// Vertices processing
|
// Vertices processing
|
||||||
// NOTE: We use meshes.vertices (default vertex position) to calculate meshes.animVertices (animated vertex position)
|
// NOTE: We use meshes.vertices (default vertex position) to calculate meshes.animVertices (animated vertex position)
|
||||||
animVertex = (Vector3){ model.meshes[m].vertices[vCounter], model.meshes[m].vertices[vCounter + 1], model.meshes[m].vertices[vCounter + 2] };
|
animVertex = (Vector3){ model.meshes[m].vertices[vCounter], model.meshes[m].vertices[vCounter + 1], model.meshes[m].vertices[vCounter + 2] };
|
||||||
animVertex = Vector3Multiply(animVertex, outScale);
|
animVertex = Vector3MultiplyV(animVertex, outScale);
|
||||||
animVertex = Vector3Subtract(animVertex, inTranslation);
|
animVertex = Vector3SubtractV(animVertex, inTranslation);
|
||||||
animVertex = Vector3RotateByQuaternion(animVertex, QuaternionMultiply(outRotation, QuaternionInvert(inRotation)));
|
animVertex = Vector3RotateByQuaternion(animVertex, QuaternionMultiply(outRotation, QuaternionInvert(inRotation)));
|
||||||
animVertex = Vector3Add(animVertex, outTranslation);
|
animVertex = Vector3AddV(animVertex, outTranslation);
|
||||||
model.meshes[m].animVertices[vCounter] = animVertex.x;
|
model.meshes[m].animVertices[vCounter] = animVertex.x;
|
||||||
model.meshes[m].animVertices[vCounter + 1] = animVertex.y;
|
model.meshes[m].animVertices[vCounter + 1] = animVertex.y;
|
||||||
model.meshes[m].animVertices[vCounter + 2] = animVertex.z;
|
model.meshes[m].animVertices[vCounter + 2] = animVertex.z;
|
||||||
|
|
@ -1914,7 +1914,7 @@ Mesh GenMeshHeightmap(Image heightmap, Vector3 size)
|
||||||
vC.y = mesh.vertices[nCounter + i + 7];
|
vC.y = mesh.vertices[nCounter + i + 7];
|
||||||
vC.z = mesh.vertices[nCounter + i + 8];
|
vC.z = mesh.vertices[nCounter + i + 8];
|
||||||
|
|
||||||
vN = Vector3Normalize(Vector3CrossProduct(Vector3Subtract(vB, vA), Vector3Subtract(vC, vA)));
|
vN = Vector3Normalize(Vector3CrossProduct(Vector3SubtractV(vB, vA), Vector3SubtractV(vC, vA)));
|
||||||
|
|
||||||
mesh.normals[nCounter + i] = vN.x;
|
mesh.normals[nCounter + i] = vN.x;
|
||||||
mesh.normals[nCounter + i + 1] = vN.y;
|
mesh.normals[nCounter + i + 1] = vN.y;
|
||||||
|
|
@ -2518,13 +2518,13 @@ void DrawBillboardRec(Camera camera, Texture2D texture, Rectangle sourceRec, Vec
|
||||||
right = Vector3Scale(right, sizeRatio.x/2);
|
right = Vector3Scale(right, sizeRatio.x/2);
|
||||||
up = Vector3Scale(up, sizeRatio.y/2);
|
up = Vector3Scale(up, sizeRatio.y/2);
|
||||||
|
|
||||||
Vector3 p1 = Vector3Add(right, up);
|
Vector3 p1 = Vector3AddV(right, up);
|
||||||
Vector3 p2 = Vector3Subtract(right, up);
|
Vector3 p2 = Vector3SubtractV(right, up);
|
||||||
|
|
||||||
Vector3 a = Vector3Subtract(center, p2);
|
Vector3 a = Vector3SubtractV(center, p2);
|
||||||
Vector3 b = Vector3Add(center, p1);
|
Vector3 b = Vector3AddV(center, p1);
|
||||||
Vector3 c = Vector3Add(center, p2);
|
Vector3 c = Vector3AddV(center, p2);
|
||||||
Vector3 d = Vector3Subtract(center, p1);
|
Vector3 d = Vector3SubtractV(center, p1);
|
||||||
|
|
||||||
if (rlCheckBufferLimit(4)) rlglDraw();
|
if (rlCheckBufferLimit(4)) rlglDraw();
|
||||||
|
|
||||||
|
|
@ -2585,7 +2585,7 @@ bool CheckCollisionSpheres(Vector3 centerA, float radiusA, Vector3 centerB, floa
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Check for distances squared to avoid sqrtf()
|
// Check for distances squared to avoid sqrtf()
|
||||||
if (Vector3DotProduct(Vector3Subtract(centerB, centerA), Vector3Subtract(centerB, centerA)) <= (radiusA + radiusB)*(radiusA + radiusB)) collision = true;
|
if (Vector3DotProduct(Vector3SubtractV(centerB, centerA), Vector3SubtractV(centerB, centerA)) <= (radiusA + radiusB)*(radiusA + radiusB)) collision = true;
|
||||||
|
|
||||||
return collision;
|
return collision;
|
||||||
}
|
}
|
||||||
|
|
@ -2632,7 +2632,7 @@ bool CheckCollisionRaySphere(Ray ray, Vector3 center, float radius)
|
||||||
{
|
{
|
||||||
bool collision = false;
|
bool collision = false;
|
||||||
|
|
||||||
Vector3 raySpherePos = Vector3Subtract(center, ray.position);
|
Vector3 raySpherePos = Vector3SubtractV(center, ray.position);
|
||||||
float distance = Vector3Length(raySpherePos);
|
float distance = Vector3Length(raySpherePos);
|
||||||
float vector = Vector3DotProduct(raySpherePos, ray.direction);
|
float vector = Vector3DotProduct(raySpherePos, ray.direction);
|
||||||
float d = radius*radius - (distance*distance - vector*vector);
|
float d = radius*radius - (distance*distance - vector*vector);
|
||||||
|
|
@ -2647,7 +2647,7 @@ bool CheckCollisionRaySphereEx(Ray ray, Vector3 center, float radius, Vector3 *c
|
||||||
{
|
{
|
||||||
bool collision = false;
|
bool collision = false;
|
||||||
|
|
||||||
Vector3 raySpherePos = Vector3Subtract(center, ray.position);
|
Vector3 raySpherePos = Vector3SubtractV(center, ray.position);
|
||||||
float distance = Vector3Length(raySpherePos);
|
float distance = Vector3Length(raySpherePos);
|
||||||
float vector = Vector3DotProduct(raySpherePos, ray.direction);
|
float vector = Vector3DotProduct(raySpherePos, ray.direction);
|
||||||
float d = radius*radius - (distance*distance - vector*vector);
|
float d = radius*radius - (distance*distance - vector*vector);
|
||||||
|
|
@ -2661,7 +2661,7 @@ bool CheckCollisionRaySphereEx(Ray ray, Vector3 center, float radius, Vector3 *c
|
||||||
else collisionDistance = vector - sqrtf(d);
|
else collisionDistance = vector - sqrtf(d);
|
||||||
|
|
||||||
// Calculate collision point
|
// Calculate collision point
|
||||||
Vector3 cPoint = Vector3Add(ray.position, Vector3Scale(ray.direction, collisionDistance));
|
Vector3 cPoint = Vector3AddV(ray.position, Vector3Scale(ray.direction, collisionDistance));
|
||||||
|
|
||||||
collisionPoint->x = cPoint.x;
|
collisionPoint->x = cPoint.x;
|
||||||
collisionPoint->y = cPoint.y;
|
collisionPoint->y = cPoint.y;
|
||||||
|
|
@ -2752,8 +2752,8 @@ RayHitInfo GetCollisionRayTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3)
|
||||||
RayHitInfo result = {0};
|
RayHitInfo result = {0};
|
||||||
|
|
||||||
// Find vectors for two edges sharing V1
|
// Find vectors for two edges sharing V1
|
||||||
edge1 = Vector3Subtract(p2, p1);
|
edge1 = Vector3SubtractV(p2, p1);
|
||||||
edge2 = Vector3Subtract(p3, p1);
|
edge2 = Vector3SubtractV(p3, p1);
|
||||||
|
|
||||||
// Begin calculating determinant - also used to calculate u parameter
|
// Begin calculating determinant - also used to calculate u parameter
|
||||||
p = Vector3CrossProduct(ray.direction, edge2);
|
p = Vector3CrossProduct(ray.direction, edge2);
|
||||||
|
|
@ -2767,7 +2767,7 @@ RayHitInfo GetCollisionRayTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3)
|
||||||
invDet = 1.0f/det;
|
invDet = 1.0f/det;
|
||||||
|
|
||||||
// Calculate distance from V1 to ray origin
|
// Calculate distance from V1 to ray origin
|
||||||
tv = Vector3Subtract(ray.position, p1);
|
tv = Vector3SubtractV(ray.position, p1);
|
||||||
|
|
||||||
// Calculate u parameter and test bound
|
// Calculate u parameter and test bound
|
||||||
u = Vector3DotProduct(tv, p)*invDet;
|
u = Vector3DotProduct(tv, p)*invDet;
|
||||||
|
|
@ -2793,7 +2793,7 @@ RayHitInfo GetCollisionRayTriangle(Ray ray, Vector3 p1, Vector3 p2, Vector3 p3)
|
||||||
result.distance = t;
|
result.distance = t;
|
||||||
result.hit = true;
|
result.hit = true;
|
||||||
result.normal = Vector3Normalize(Vector3CrossProduct(edge1, edge2));
|
result.normal = Vector3Normalize(Vector3CrossProduct(edge1, edge2));
|
||||||
result.position = Vector3Add(ray.position, Vector3Scale(ray.direction, t));
|
result.position = Vector3AddV(ray.position, Vector3Scale(ray.direction, t));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -2815,7 +2815,7 @@ RayHitInfo GetCollisionRayGround(Ray ray, float groundHeight)
|
||||||
result.hit = true;
|
result.hit = true;
|
||||||
result.distance = distance;
|
result.distance = distance;
|
||||||
result.normal = (Vector3){ 0.0, 1.0, 0.0 };
|
result.normal = (Vector3){ 0.0, 1.0, 0.0 };
|
||||||
result.position = Vector3Add(ray.position, Vector3Scale(ray.direction, distance));
|
result.position = Vector3AddV(ray.position, Vector3Scale(ray.direction, distance));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3315,8 +3315,8 @@ static Model LoadIQM(const char *fileName)
|
||||||
{
|
{
|
||||||
model.bindPose[i].rotation = QuaternionMultiply(model.bindPose[model.bones[i].parent].rotation, model.bindPose[i].rotation);
|
model.bindPose[i].rotation = QuaternionMultiply(model.bindPose[model.bones[i].parent].rotation, model.bindPose[i].rotation);
|
||||||
model.bindPose[i].translation = Vector3RotateByQuaternion(model.bindPose[i].translation, model.bindPose[model.bones[i].parent].rotation);
|
model.bindPose[i].translation = Vector3RotateByQuaternion(model.bindPose[i].translation, model.bindPose[model.bones[i].parent].rotation);
|
||||||
model.bindPose[i].translation = Vector3Add(model.bindPose[i].translation, model.bindPose[model.bones[i].parent].translation);
|
model.bindPose[i].translation = Vector3AddV(model.bindPose[i].translation, model.bindPose[model.bones[i].parent].translation);
|
||||||
model.bindPose[i].scale = Vector3Multiply(model.bindPose[i].scale, model.bindPose[model.bones[i].parent].scale);
|
model.bindPose[i].scale = Vector3MultiplyV(model.bindPose[i].scale, model.bindPose[model.bones[i].parent].scale);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
116
src/raymath.h
116
src/raymath.h
|
|
@ -173,19 +173,33 @@ RMDEF Vector2 Vector2One(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add two vectors (v1 + v2)
|
// Add two vectors (v1 + v2)
|
||||||
RMDEF Vector2 Vector2Add(Vector2 v1, Vector2 v2)
|
RMDEF Vector2 Vector2AddV(Vector2 v1, Vector2 v2)
|
||||||
{
|
{
|
||||||
Vector2 result = { v1.x + v2.x, v1.y + v2.y };
|
Vector2 result = { v1.x + v2.x, v1.y + v2.y };
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add vector and float value
|
||||||
|
RMDEF Vector2 Vector2Add(Vector2 v, float add)
|
||||||
|
{
|
||||||
|
Vector2 result = { v.x + add, v.y + add };
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Subtract two vectors (v1 - v2)
|
// Subtract two vectors (v1 - v2)
|
||||||
RMDEF Vector2 Vector2Subtract(Vector2 v1, Vector2 v2)
|
RMDEF Vector2 Vector2SubtractV(Vector2 v1, Vector2 v2)
|
||||||
{
|
{
|
||||||
Vector2 result = { v1.x - v2.x, v1.y - v2.y };
|
Vector2 result = { v1.x - v2.x, v1.y - v2.y };
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Subtract vector by float value
|
||||||
|
RMDEF Vector2 Vector2Subtract(Vector2 v, float sub)
|
||||||
|
{
|
||||||
|
Vector2 result = { v.x - sub, v.y - sub };
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate vector length
|
// Calculate vector length
|
||||||
RMDEF float Vector2Length(Vector2 v)
|
RMDEF float Vector2Length(Vector2 v)
|
||||||
{
|
{
|
||||||
|
|
@ -229,6 +243,13 @@ RMDEF Vector2 Vector2MultiplyV(Vector2 v1, Vector2 v2)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Multiply vector by float value
|
||||||
|
RMDEF Vector2 Vector2Multiply(Vector2 v, float mul)
|
||||||
|
{
|
||||||
|
Vector2 result = { v.x*mul, v.y*mul };
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Negate vector
|
// Negate vector
|
||||||
RMDEF Vector2 Vector2Negate(Vector2 v)
|
RMDEF Vector2 Vector2Negate(Vector2 v)
|
||||||
{
|
{
|
||||||
|
|
@ -295,19 +316,33 @@ RMDEF Vector3 Vector3One(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add two vectors
|
// Add two vectors
|
||||||
RMDEF Vector3 Vector3Add(Vector3 v1, Vector3 v2)
|
RMDEF Vector3 Vector3AddV(Vector3 v1, Vector3 v2)
|
||||||
{
|
{
|
||||||
Vector3 result = { v1.x + v2.x, v1.y + v2.y, v1.z + v2.z };
|
Vector3 result = { v1.x + v2.x, v1.y + v2.y, v1.z + v2.z };
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add vector and float value
|
||||||
|
RMDEF Vector3 Vector3Add(Vector3 v, float add)
|
||||||
|
{
|
||||||
|
Vector3 result = { v.x + add, v.y + add, v.z + add };
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Subtract two vectors
|
// Subtract two vectors
|
||||||
RMDEF Vector3 Vector3Subtract(Vector3 v1, Vector3 v2)
|
RMDEF Vector3 Vector3SubtractV(Vector3 v1, Vector3 v2)
|
||||||
{
|
{
|
||||||
Vector3 result = { v1.x - v2.x, v1.y - v2.y, v1.z - v2.z };
|
Vector3 result = { v1.x - v2.x, v1.y - v2.y, v1.z - v2.z };
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Subtract vector by float value
|
||||||
|
RMDEF Vector3 Vector3Subtract(Vector3 v, float sub)
|
||||||
|
{
|
||||||
|
Vector3 result = { v.x - sub, v.y - sub, v.z - sub };
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Multiply vector by scalar
|
// Multiply vector by scalar
|
||||||
RMDEF Vector3 Vector3Scale(Vector3 v, float scalar)
|
RMDEF Vector3 Vector3Scale(Vector3 v, float scalar)
|
||||||
{
|
{
|
||||||
|
|
@ -316,12 +351,19 @@ RMDEF Vector3 Vector3Scale(Vector3 v, float scalar)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Multiply vector by vector
|
// Multiply vector by vector
|
||||||
RMDEF Vector3 Vector3Multiply(Vector3 v1, Vector3 v2)
|
RMDEF Vector3 Vector3MultiplyV(Vector3 v1, Vector3 v2)
|
||||||
{
|
{
|
||||||
Vector3 result = { v1.x*v2.x, v1.y*v2.y, v1.z*v2.z };
|
Vector3 result = { v1.x*v2.x, v1.y*v2.y, v1.z*v2.z };
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Multiply vector by float value
|
||||||
|
RMDEF Vector3 Vector3Multiply(Vector3 v, float mul)
|
||||||
|
{
|
||||||
|
Vector3 result = { v.x*mul, v.y*mul, v.z*mul };
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Calculate two vectors cross product
|
// Calculate two vectors cross product
|
||||||
RMDEF Vector3 Vector3CrossProduct(Vector3 v1, Vector3 v2)
|
RMDEF Vector3 Vector3CrossProduct(Vector3 v1, Vector3 v2)
|
||||||
{
|
{
|
||||||
|
|
@ -515,9 +557,9 @@ RMDEF Vector3 Vector3Barycenter(Vector3 p, Vector3 a, Vector3 b, Vector3 c)
|
||||||
{
|
{
|
||||||
//Vector v0 = b - a, v1 = c - a, v2 = p - a;
|
//Vector v0 = b - a, v1 = c - a, v2 = p - a;
|
||||||
|
|
||||||
Vector3 v0 = Vector3Subtract(b, a);
|
Vector3 v0 = Vector3SubtractV(b, a);
|
||||||
Vector3 v1 = Vector3Subtract(c, a);
|
Vector3 v1 = Vector3SubtractV(c, a);
|
||||||
Vector3 v2 = Vector3Subtract(p, a);
|
Vector3 v2 = Vector3SubtractV(p, a);
|
||||||
float d00 = Vector3DotProduct(v0, v0);
|
float d00 = Vector3DotProduct(v0, v0);
|
||||||
float d01 = Vector3DotProduct(v0, v1);
|
float d01 = Vector3DotProduct(v0, v1);
|
||||||
float d11 = Vector3DotProduct(v1, v1);
|
float d11 = Vector3DotProduct(v1, v1);
|
||||||
|
|
@ -982,7 +1024,7 @@ RMDEF Matrix MatrixLookAt(Vector3 eye, Vector3 target, Vector3 up)
|
||||||
{
|
{
|
||||||
Matrix result = { 0 };
|
Matrix result = { 0 };
|
||||||
|
|
||||||
Vector3 z = Vector3Subtract(eye, target);
|
Vector3 z = Vector3SubtractV(eye, target);
|
||||||
z = Vector3Normalize(z);
|
z = Vector3Normalize(z);
|
||||||
Vector3 x = Vector3CrossProduct(up, z);
|
Vector3 x = Vector3CrossProduct(up, z);
|
||||||
x = Vector3Normalize(x);
|
x = Vector3Normalize(x);
|
||||||
|
|
@ -1040,6 +1082,62 @@ RMDEF float16 MatrixToFloatV(Matrix mat)
|
||||||
// Module Functions Definition - Quaternion math
|
// Module Functions Definition - Quaternion math
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
// Add two quaternions
|
||||||
|
RMDEF Quaternion QuaternionAddQ(Quaternion q1, Quaternion q2)
|
||||||
|
{
|
||||||
|
Quaternion result = {q1.x + q2.x, q1.y + q2.y, q1.z + q2.z, q1.w + q2.w};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add quaternion and float value
|
||||||
|
RMDEF Quaternion QuaternionAdd(Quaternion q, float add)
|
||||||
|
{
|
||||||
|
Quaternion result = {q.x + add, q.y + add, q.z + add, q.w + add};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subtract two quaternions
|
||||||
|
RMDEF Quaternion QuaternionSubtractQ(Quaternion q1, Quaternion q2)
|
||||||
|
{
|
||||||
|
Quaternion result = {q1.x - q2.x, q1.y - q2.y, q1.z - q2.z, q1.w - q2.w};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Subtract quaternion and float value
|
||||||
|
RMDEF Quaternion QuaternionSubtract(Quaternion q, float sub)
|
||||||
|
{
|
||||||
|
Quaternion result = {q.x - sub, q.y - sub, q.z - sub, q.w - sub};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multiply two quaternions
|
||||||
|
RMDEF Quaternion QuaternionMultiplyQ(Quaternion q1, Quaternion q2)
|
||||||
|
{
|
||||||
|
Quaternion result = {q1.x * q2.x, q1.y * q2.y, q1.z * q2.z, q1.w * q2.w};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Multiply quaternion by float value
|
||||||
|
RMDEF Quaternion QuaternionMultiply(Quaternion q, float sub)
|
||||||
|
{
|
||||||
|
Quaternion result = {q.x * sub, q.y * sub, q.z * sub, q.w * sub};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Divide two quaternions
|
||||||
|
RMDEF Quaternion QuaternionDivideQ(Quaternion q1, Quaternion q2)
|
||||||
|
{
|
||||||
|
Quaternion result = {q1.x / q2.x, q1.y / q2.y, q1.z / q2.z, q1.w / q2.w};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Divide quaternion by float value
|
||||||
|
RMDEF Quaternion QuaternionDivide(Quaternion q, float sub)
|
||||||
|
{
|
||||||
|
Quaternion result = {q.x / sub, q.y / sub, q.z / sub, q.w / sub};
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns identity quaternion
|
// Returns identity quaternion
|
||||||
RMDEF Quaternion QuaternionIdentity(void)
|
RMDEF Quaternion QuaternionIdentity(void)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user