mirror of
https://github.com/thepigeongenerator/sdl_template.git
synced 2025-12-17 05:55:47 +01:00
gename to , to , to and added a function called for vector-on-vector division
This commit is contained in:
@@ -19,17 +19,22 @@ static inline float2 float2_sub(float2 v1, float2 v2) {
|
||||
}
|
||||
|
||||
// multiplies one float2 by another
|
||||
static inline float2 float2_mlt(float2 v1, float2 v2) {
|
||||
static inline float2 float2_mul(float2 v1, float2 v2) {
|
||||
return (float2){v1.x * v2.x, v1.y * v2.y};
|
||||
}
|
||||
|
||||
// scales the float2 by some value
|
||||
static inline float2 float2_scale(float2 v, float n) {
|
||||
// divides one float2 by another
|
||||
static inline float2 float2_div(float2 v1, float2 v2) {
|
||||
return (float2){v1.x / v2.x, v1.y / v2.y};
|
||||
}
|
||||
|
||||
// preforms a scalar multiplication upon the float2 (multiplies the float2 by some value)
|
||||
static inline float2 float2_mul_s(float2 v, float n) {
|
||||
return (float2){v.x * n, v.y * n};
|
||||
}
|
||||
|
||||
// divides the float2 by some value
|
||||
static inline float2 float2_div(float2 v, float n) {
|
||||
// preforms a scalar division upon the float2 (divides the float2 by some value)
|
||||
static inline float2 float2_div_s(float2 v, float n) {
|
||||
return (float2){v.x / n, v.y / n};
|
||||
}
|
||||
|
||||
@@ -46,7 +51,7 @@ static inline float float2_mag(float2 v) {
|
||||
// normalizes the float2
|
||||
static inline float2 float2_norm(float2 v) {
|
||||
float s = 1.0F / float2_mag(v); // get the scaling factor
|
||||
return float2_scale(v, s); // scale the vector by the scaling factor (slightly more efficient than dividing)
|
||||
return float2_mul_s(v, s); // scale the vector by the scaling factor (slightly more efficient than dividing)
|
||||
}
|
||||
|
||||
// gets the dot product of two float2s
|
||||
|
||||
@@ -20,17 +20,22 @@ static inline float3 float3_sub(float3 v1, float3 v2) {
|
||||
}
|
||||
|
||||
// multiplies one float3 by another
|
||||
static inline float3 float3_mlt(float3 v1, float3 v2) {
|
||||
static inline float3 float3_mul(float3 v1, float3 v2) {
|
||||
return (float3){v1.x * v2.x, v1.y * v2.y, v1.z * v2.z};
|
||||
}
|
||||
|
||||
// scales the float3 by some value
|
||||
static inline float3 float3_scale(float3 v, float n) {
|
||||
// divides one float3 by another
|
||||
static inline float3 float3_div(float3 v1, float3 v2) {
|
||||
return (float3){v1.x / v2.x, v1.y / v2.y, v1.z / v2.z};
|
||||
}
|
||||
|
||||
// preforms a scalar multiplication upon the float3 (multiplies the float3 by some value)
|
||||
static inline float3 float3_mul_s(float3 v, float n) {
|
||||
return (float3){v.x * n, v.y * n, v.z * n};
|
||||
}
|
||||
|
||||
// divides the float3 by some value
|
||||
static inline float3 float3_div(float3 v, float n) {
|
||||
// preforms a scalar division upon the float3 (divides the float3 by some value)
|
||||
static inline float3 float3_div_s(float3 v, float n) {
|
||||
return (float3){v.x / n, v.y / n, v.z / n};
|
||||
}
|
||||
|
||||
@@ -47,7 +52,7 @@ static inline float float3_mag(float3 v) {
|
||||
// normalizes the float3
|
||||
static inline float3 float3_norm(float3 v) {
|
||||
float s = 1.0F / float3_mag(v); // get the scaling factor
|
||||
return float3_scale(v, s); // scale the vector by the scaling factor (slightly more efficient than dividing)
|
||||
return float3_mul_s(v, s); // scale the vector by the scaling factor (slightly more efficient than dividing)
|
||||
}
|
||||
|
||||
// gets the dot product of two float3s
|
||||
|
||||
@@ -21,17 +21,22 @@ static inline float4 float4_sub(float4 v1, float4 v2) {
|
||||
}
|
||||
|
||||
// multiplies one float4 by another
|
||||
static inline float4 float4_mlt(float4 v1, float4 v2) {
|
||||
static inline float4 float4_mul(float4 v1, float4 v2) {
|
||||
return (float4){v1.x * v2.x, v1.y * v2.y, v1.z * v2.z, v1.w * v2.w};
|
||||
}
|
||||
|
||||
// scales the float4 by some value
|
||||
static inline float4 float4_scale(float4 v, float n) {
|
||||
// divides one float4 by another
|
||||
static inline float4 float4_div(float4 v1, float4 v2) {
|
||||
return (float4){v1.x / v2.x, v1.y / v2.y, v1.z / v2.z, v1.w / v2.w};
|
||||
}
|
||||
|
||||
// preforms a scalar multiplication upon the float4 (multiplies the float4 by some value)
|
||||
static inline float4 float4_mul_s(float4 v, float n) {
|
||||
return (float4){v.x * n, v.y * n, v.z * n, v.w * n};
|
||||
}
|
||||
|
||||
// divides the float4 by some value
|
||||
static inline float4 float4_div(float4 v, float n) {
|
||||
// preforms a scalar division upon the float4 (divides the float4 by some value)
|
||||
static inline float4 float4_div_s(float4 v, float n) {
|
||||
return (float4){v.x / n, v.y / n, v.z / n, v.w / n};
|
||||
}
|
||||
|
||||
@@ -48,7 +53,7 @@ static inline float float4_mag(float4 v) {
|
||||
// normalizes the float4
|
||||
static inline float4 float4_norm(float4 v) {
|
||||
float s = 1.0F / float4_mag(v); // get the scaling factor
|
||||
return float4_scale(v, s); // scale the vector by the scaling factor (slightly more efficient than dividing)
|
||||
return float4_mul_s(v, s); // scale the vector by the scaling factor (slightly more efficient than dividing)
|
||||
}
|
||||
|
||||
// gets the dot product of two float4s
|
||||
|
||||
Reference in New Issue
Block a user