summaryrefslogtreecommitdiff
path: root/prb_math.h
diff options
context:
space:
mode:
Diffstat (limited to 'prb_math.h')
-rw-r--r--prb_math.h43
1 files changed, 9 insertions, 34 deletions
diff --git a/prb_math.h b/prb_math.h
index 8f188f4..4e4a378 100644
--- a/prb_math.h
+++ b/prb_math.h
@@ -29,31 +29,6 @@
#define QUAT_IDENTITY (v4){0.0f, 0.0f, 0.0f, 1.0f}
-/* TODO(pryazha): Implement trigonometry functions */
-f32 fsin(f32 a)
-{
- f32 result = sinf(a);
- return result;
-}
-
-f32 fcos(f32 a)
-{
- f32 result = cosf(a);
- return result;
-}
-
-f32 ftan(f32 a)
-{
- f32 result = tanf(a);
- return result;
-}
-
-f32 fsqrt(f32 a)
-{
- f32 result = sqrtf(a);
- return result;
-}
-
// vectors
v2 v2_fill(f32 x)
{
@@ -105,7 +80,7 @@ f32 v2_len2(v2 a)
f32 v2_len(v2 a)
{
- f32 v = fsqrt(v2_len2(a));
+ f32 v = sqrtf(v2_len2(a));
return v;
}
@@ -186,7 +161,7 @@ f32 v3_len2(v3 a)
f32 v3_len(v3 a)
{
- f32 v = fsqrt(v3_len2(a));
+ f32 v = sqrtf(v3_len2(a));
return v;
}
@@ -255,7 +230,7 @@ f32 v4_len2(v4 a)
f32 v4_len(v4 a)
{
- f32 v = fsqrt(v4_len2(a));
+ f32 v = sqrtf(v4_len2(a));
return v;
}
@@ -405,14 +380,14 @@ mat4 mat4_scale(mat4 m, v3 v)
mat4 mat4_rotate(mat4 mat, v3 angles)
{
f32 angle = deg2rad(angles.x);
- f32 cx = fcos(angle);
- f32 sx = fsin(angle);
+ f32 cx = cosf(angle);
+ f32 sx = sinf(angle);
angle = deg2rad(angles.y);
- f32 cy = fcos(angle);
- f32 sy = fsin(angle);
+ f32 cy = cosf(angle);
+ f32 sy = sinf(angle);
angle = deg2rad(angles.z);
- f32 cz = fcos(angle);
- f32 sz = fsin(angle);
+ f32 cz = cosf(angle);
+ f32 sz = sinf(angle);
v3 x = {cy*cz, sx*sy*cz+cx*sz, -cx*sy*cz+sx*sz};
v3 y = {-cy*sz, -sx*sy*sz+cx*cz, cx*sy*sz+sx*cz};