mirror of
https://github.com/thepigeongenerator/sdl_template.git
synced 2025-12-17 05:55:47 +01:00
add negate function to vector definitions
This commit is contained in:
@@ -38,6 +38,11 @@ static inline float2 float2_div_s(float2 v, float n) {
|
||||
return (float2){v.x / n, v.y / n};
|
||||
}
|
||||
|
||||
// negates the float2 (-v)
|
||||
static inline float2 float2_neg(float2 v) {
|
||||
return (float2){-v.x, -v.y};
|
||||
}
|
||||
|
||||
// gets the squared magnitude/length of float2
|
||||
static inline float float2_mag2(float2 v) {
|
||||
return (v.x * v.x) + (v.y * v.y);
|
||||
|
||||
@@ -39,6 +39,10 @@ static inline float3 float3_div_s(float3 v, float n) {
|
||||
return (float3){v.x / n, v.y / n, v.z / n};
|
||||
}
|
||||
|
||||
static inline float3 float3_neg(float3 v) {
|
||||
return (float3){-v.x, -v.y, -v.z};
|
||||
}
|
||||
|
||||
// gets the squared magnitude/length of float3
|
||||
static inline float float3_mag2(float3 v) {
|
||||
return (v.x * v.x) + (v.y * v.y) + (v.z * v.z);
|
||||
|
||||
@@ -40,6 +40,10 @@ static inline float4 float4_div_s(float4 v, float n) {
|
||||
return (float4){v.x / n, v.y / n, v.z / n, v.w / n};
|
||||
}
|
||||
|
||||
static inline float4 float4_neg(float4 v) {
|
||||
return (float4){-v.x, -v.y, -v.z, -v.w};
|
||||
}
|
||||
|
||||
// gets the squared magnitude/length of float4
|
||||
static inline float float4_mag2(float4 v) {
|
||||
return (v.x * v.x) + (v.y * v.y) + (v.z * v.z) + (v.w * v.w);
|
||||
|
||||
Reference in New Issue
Block a user