Math.hx 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. package lua;
  2. import haxe.extern.Rest;
  3. /**
  4. Mathematical Functions
  5. **/
  6. @:native("_G.math")
  7. extern class Math {
  8. /**
  9. The value of pi.
  10. **/
  11. static var pi(default,never) : Float;
  12. /**
  13. The value HUGE_VAL, a value larger than or equal to any other numerical value.
  14. **/
  15. static var huge(default,never) : Float;
  16. /**
  17. Returns the absolute value of x.
  18. **/
  19. static function abs (x : Float) : Float;
  20. /**
  21. Returns the smallest integer larger than or equal to x.
  22. **/
  23. static function ceil (x : Float) : Int;
  24. /**
  25. Returns the largest integer smaller than or equal to x.
  26. **/
  27. static function floor(x : Float) : Int;
  28. /**
  29. Returns the arc cosine of x (in radians).
  30. **/
  31. static function acos (x : Float) : Float;
  32. /**
  33. Returns the arc sine of x (in radians).
  34. **/
  35. static function asin (x : Float) : Float;
  36. /**
  37. Returns the arc tangent of x (in radians).
  38. **/
  39. static function atan (x : Float) : Float;
  40. /**
  41. Returns the arc tangent of y/x (in radians), but uses the signs of both parameters to find the quadrant of the result.
  42. (It also handles correctly the case of x being zero.)
  43. **/
  44. static function atan2(y : Float, x : Float) : Float;
  45. /**
  46. Returns the cosine of x (assumed to be in radians).
  47. **/
  48. static function cos (x : Float) : Float;
  49. /**
  50. Returns the hyperbolic cosine of x.
  51. **/
  52. static function cosh (x : Float) : Float;
  53. /**
  54. Returns the sine of x (assumed to be in radians).
  55. **/
  56. static function sin (x : Float) : Float;
  57. /**
  58. Returns the hyperbolic sine of x.
  59. **/
  60. static function sinh (x : Float) : Float;
  61. /**
  62. Returns the tangent of x (assumed to be in radians)
  63. **/
  64. static function tan (x : Float) : Float;
  65. /**
  66. Returns the hyperbolic tangent of x.
  67. **/
  68. static function tanh (x : Float) : Float;
  69. /**
  70. Returns the angle x (given in degrees) in radians.
  71. **/
  72. static function rad (x : Float) : Float;
  73. /**
  74. Returns two numbers, the integral part of x and the fractional part of x.
  75. **/
  76. static function modf (x : Float) : Float;
  77. /**
  78. Returns the remainder of the division of x by y that rounds the quotient towards zero.
  79. **/
  80. static function fmod (x : Float) : Float;
  81. /**
  82. Returns y-th power of x.
  83. **/
  84. static function pow (x : Float, y : Float) : Float;
  85. /**
  86. Returns the square root of x.
  87. **/
  88. static function sqrt (x : Float) : Float;
  89. /**
  90. Returns the value e^x.
  91. **/
  92. static function exp (x : Float) : Float;
  93. /**
  94. Returns m and e such that x = m2^e, e is an integer and the absolute value of m is in the range [0.5, 1) (or zero when x is zero).
  95. **/
  96. static function frexp(x : Float) : MathFrexpResult;
  97. /**
  98. Returns m2^e (e should be an integer).
  99. **/
  100. static function ldexp(m : Float, e : Int) : Float;
  101. /**
  102. Returns the natural logarithm of x.
  103. **/
  104. static function log (x : Float) : Float;
  105. /**
  106. Returns the base-10 logarithm of x.
  107. **/
  108. static function log10(x : Float) : Float;
  109. /**
  110. Returns the maximum value among its arguments.
  111. **/
  112. static function max (x : Float, numbers : Rest<Float>) : Float;
  113. /**
  114. Returns the minimum value among its arguments.
  115. **/
  116. static function min (x : Float, numbers : Rest<Float>) : Float;
  117. /**
  118. Returns the angle x (given in radians) in degrees.
  119. **/
  120. static function deg (x : Float) : Float;
  121. /**
  122. This function is an interface to the simple pseudo-random generator function rand provided by ANSI C.
  123. (No guarantees can be given for its statistical properties.)
  124. When called without arguments, returns a uniform pseudo-random real number in the range [0,1).
  125. When called with an integer number `m`, returns a uniform pseudo-random integer in the range [1, m].
  126. When called with two integer numbers `m` and `n`, returns a uniform pseudo-random integer in the range [m, n].
  127. **/
  128. static function random(?m:Float, ?n:Float) : Float;
  129. /**
  130. Sets `x` as the "seed" for the pseudo-random generator: equal seeds produce equal sequences of numbers.
  131. **/
  132. static function randomseed(x : Float) : Float;
  133. }
  134. /**
  135. The return value of `Math.frexp`.
  136. **/
  137. @:multiReturn extern class MathFrexpResult {
  138. var m:Float;
  139. var e:Int;
  140. }