Math.hx 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (C)2005-2017 Haxe Foundation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  19. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  20. * DEALINGS IN THE SOFTWARE.
  21. */
  22. @:coreApi
  23. class Math {
  24. @:hlNative("std","math_sqrt") public static function sqrt( v : Float ) : Float return 0.;
  25. @:hlNative("std","math_abs") public static function abs( v : Float ) : Float return 0.;
  26. @:hlNative("std","math_floor") public static function floor( v : Float ) : Int return 0;
  27. @:hlNative("std","math_round") public static function round( v : Float ) : Int return 0;
  28. @:hlNative("std","math_ceil") public static function ceil( v : Float ) : Int return 0;
  29. @:hlNative("std","math_isfinite") public static function isFinite( f : Float ) : Bool return true;
  30. @:hlNative("std","math_isnan") public static function isNaN( f : Float ) : Bool return false;
  31. @:hlNative("std","math_ffloor") public static function ffloor( v : Float ) : Float return 0.;
  32. @:hlNative("std","math_fround") public static function fround( v : Float ) : Float return 0.;
  33. @:hlNative("std","math_fceil") public static function fceil( v : Float ) : Float return 0.;
  34. @:hlNative("std","math_cos") public static function cos( v : Float ) : Float return 0.;
  35. @:hlNative("std","math_sin") public static function sin( v : Float ) : Float return 0.;
  36. @:hlNative("std","math_exp") public static function exp( v : Float ) : Float return 0.;
  37. @:hlNative("std","math_log") public static function log( v : Float ) : Float return 0.;
  38. @:hlNative("std","math_tan") public static function tan( v : Float ) : Float return 0.;
  39. @:hlNative("std","math_atan") public static function atan( v : Float ) : Float return 0.;
  40. @:hlNative("std","math_acos") public static function acos( v : Float ) : Float return 0.;
  41. @:hlNative("std","math_asin") public static function asin( v : Float ) : Float return 0.;
  42. @:hlNative("std","math_pow") public static function pow( v : Float, exp : Float ) : Float return 0.;
  43. @:hlNative("std","math_atan2") public static function atan2( y : Float, x : Float ) : Float return 0.;
  44. public static function random() : Float return @:privateAccess Std.rnd_float(Std.rnd);
  45. public static function min( a : Float, b : Float ) : Float return a < b || isNaN(a) ? a : b;
  46. public static function max( a : Float, b : Float ) : Float return a < b || isNaN(b) ? b : a;
  47. public static var PI(default,null) : Float;
  48. public static var NaN(default,null) : Float;
  49. public static var POSITIVE_INFINITY(default,null) : Float;
  50. public static var NEGATIVE_INFINITY(default,null) : Float;
  51. static function __init__() : Void {
  52. PI = 3.1415926535897932384626433832795;
  53. NaN = 0. / 0.;
  54. POSITIVE_INFINITY = 1. / 0.;
  55. NEGATIVE_INFINITY = -1. / 0.;
  56. }
  57. }