linalg_glsl_math.odin 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. package math_linalg_glsl
  2. import "core:math"
  3. cos_f32 :: proc "c" (x: f32) -> f32 { return math.cos(x) }
  4. sin_f32 :: proc "c" (x: f32) -> f32 { return math.sin(x) }
  5. tan_f32 :: proc "c" (x: f32) -> f32 { return math.tan(x) }
  6. acos_f32 :: proc "c" (x: f32) -> f32 { return math.acos(x) }
  7. asin_f32 :: proc "c" (x: f32) -> f32 { return math.asin(x) }
  8. atan_f32 :: proc "c" (x: f32) -> f32 { return math.atan(x) }
  9. atan2_f32 :: proc "c" (y, x: f32) -> f32 { return math.atan2(y, x) }
  10. cosh_f32 :: proc "c" (x: f32) -> f32 { return math.cosh(x) }
  11. sinh_f32 :: proc "c" (x: f32) -> f32 { return math.sinh(x) }
  12. tanh_f32 :: proc "c" (x: f32) -> f32 { return math.tanh(x) }
  13. acosh_f32 :: proc "c" (x: f32) -> f32 { return math.acosh(x) }
  14. asinh_f32 :: proc "c" (x: f32) -> f32 { return math.asinh(x) }
  15. atanh_f32 :: proc "c" (x: f32) -> f32 { return math.atanh(x) }
  16. sqrt_f32 :: proc "c" (x: f32) -> f32 { return math.sqrt(x) }
  17. inversesqrt_f32 :: proc "c" (x: f32) -> f32 { return 1.0/math.sqrt(x) }
  18. pow_f32 :: proc "c" (x, y: f32) -> f32 { return math.pow(x, y) }
  19. exp_f32 :: proc "c" (x: f32) -> f32 { return math.exp(x) }
  20. log_f32 :: proc "c" (x: f32) -> f32 { return math.ln(x) }
  21. exp2_f32 :: proc "c" (x: f32) -> f32 { return math.pow(f32(2), x) }
  22. sign_f32 :: proc "c" (x: f32) -> f32 { return math.sign(x) }
  23. floor_f32 :: proc "c" (x: f32) -> f32 { return math.floor(x) }
  24. ceil_f32 :: proc "c" (x: f32) -> f32 { return math.ceil(x) }
  25. mod_f32 :: proc "c" (x, y: f32) -> f32 { return math.mod(x, y) }
  26. fract_f32 :: proc "c" (x: f32) -> f32 {
  27. if x >= 0 {
  28. return x - math.trunc(x)
  29. }
  30. return math.trunc(-x) + x
  31. }
  32. cos_f64 :: proc "c" (x: f64) -> f64 { return math.cos(x) }
  33. sin_f64 :: proc "c" (x: f64) -> f64 { return math.sin(x) }
  34. tan_f64 :: proc "c" (x: f64) -> f64 { return math.tan(x) }
  35. acos_f64 :: proc "c" (x: f64) -> f64 { return math.acos(x) }
  36. asin_f64 :: proc "c" (x: f64) -> f64 { return math.asin(x) }
  37. atan_f64 :: proc "c" (x: f64) -> f64 { return math.atan(x) }
  38. atan2_f64 :: proc "c" (y, x: f64) -> f64 { return math.atan2(y, x) }
  39. cosh_f64 :: proc "c" (x: f64) -> f64 { return math.cosh(x) }
  40. sinh_f64 :: proc "c" (x: f64) -> f64 { return math.sinh(x) }
  41. tanh_f64 :: proc "c" (x: f64) -> f64 { return math.tanh(x) }
  42. acosh_f64 :: proc "c" (x: f64) -> f64 { return math.acosh(x) }
  43. asinh_f64 :: proc "c" (x: f64) -> f64 { return math.asinh(x) }
  44. atanh_f64 :: proc "c" (x: f64) -> f64 { return math.atanh(x) }
  45. sqrt_f64 :: proc "c" (x: f64) -> f64 { return math.sqrt(x) }
  46. inversesqrt_f64 :: proc "c" (x: f64) -> f64 { return 1.0/math.sqrt(x) }
  47. pow_f64 :: proc "c" (x, y: f64) -> f64 { return math.pow(x, y) }
  48. exp_f64 :: proc "c" (x: f64) -> f64 { return math.exp(x) }
  49. log_f64 :: proc "c" (x: f64) -> f64 { return math.ln(x) }
  50. exp2_f64 :: proc "c" (x: f64) -> f64 { return math.pow(f64(2), x) }
  51. sign_f64 :: proc "c" (x: f64) -> f64 { return math.sign(x) }
  52. floor_f64 :: proc "c" (x: f64) -> f64 { return math.floor(x) }
  53. ceil_f64 :: proc "c" (x: f64) -> f64 { return math.ceil(x) }
  54. mod_f64 :: proc "c" (x, y: f64) -> f64 { return math.mod(x, y) }
  55. fract_f64 :: proc "c" (x: f64) -> f64 {
  56. if x >= 0 {
  57. return x - math.trunc(x)
  58. }
  59. return math.trunc(-x) + x
  60. }