mirror of
https://github.com/thepigeongenerator/sdl_template.git
synced 2025-12-17 05:55:47 +01:00
rename 'len'/'len2' functions with 'mag' and 'mag2'
This commit is contained in:
@@ -33,19 +33,19 @@ static inline float2 float2_div(float2 v, float n) {
|
||||
return (float2){v.x / n, v.y / n};
|
||||
}
|
||||
|
||||
// gets the squared length of float2
|
||||
static inline float float2_len2(float2 v) {
|
||||
// gets the squared magnitude/length of float2
|
||||
static inline float float2_mag2(float2 v) {
|
||||
return (v.x * v.x) + (v.y * v.y);
|
||||
}
|
||||
|
||||
// gets the length of float2 (magnitude)
|
||||
static inline float float2_len(float2 v) {
|
||||
return sqrtf(float2_len2(v));
|
||||
// gets the length of float2 (length)
|
||||
static inline float float2_mag(float2 v) {
|
||||
return sqrtf(float2_mag2(v));
|
||||
}
|
||||
|
||||
// normalizes the float2
|
||||
static inline float2 float2_norm(float2 v) {
|
||||
float len = float2_len(v);
|
||||
float len = float2_mag(v);
|
||||
return float2_div(v, len);
|
||||
}
|
||||
|
||||
|
||||
@@ -34,19 +34,19 @@ static inline float3 float3_div(float3 v, float n) {
|
||||
return (float3){v.x / n, v.y / n, v.z / n};
|
||||
}
|
||||
|
||||
// gets the squared length of float3
|
||||
static inline float float3_len2(float3 v) {
|
||||
// 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);
|
||||
}
|
||||
|
||||
// gets the length of float3 (magnitude)
|
||||
static inline float float3_len(float3 v) {
|
||||
return sqrtf(float3_len2(v));
|
||||
// gets the length of float3 (length)
|
||||
static inline float float3_mag(float3 v) {
|
||||
return sqrtf(float3_mag2(v));
|
||||
}
|
||||
|
||||
// normalizes the float3
|
||||
static inline float3 float3_norm(float3 v) {
|
||||
float len = float3_len(v);
|
||||
float len = float3_mag(v);
|
||||
return float3_div(v, len);
|
||||
}
|
||||
|
||||
|
||||
@@ -35,19 +35,19 @@ static inline float4 float4_div(float4 v, float n) {
|
||||
return (float4){v.x / n, v.y / n, v.z / n, v.w / n};
|
||||
}
|
||||
|
||||
// gets the squared length of float4
|
||||
static inline float float4_len2(float4 v) {
|
||||
return (v.x * v.x) + (v.y * v.y) + (v.z * v.z);
|
||||
// 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);
|
||||
}
|
||||
|
||||
// gets the length of float4 (magnitude)
|
||||
static inline float float4_len(float4 v) {
|
||||
return sqrtf(float4_len2(v));
|
||||
// gets the length of float4 (length)
|
||||
static inline float float4_mag(float4 v) {
|
||||
return sqrtf(float4_mag2(v));
|
||||
}
|
||||
|
||||
// normalizes the float4
|
||||
static inline float4 float3_norm(float4 v) {
|
||||
float len = float4_len(v);
|
||||
static inline float4 float4_norm(float4 v) {
|
||||
float len = float4_mag(v);
|
||||
return float4_div(v, len);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user