PhpMath__.hx 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. * Copyright (c) 2005, The haXe Project Contributors
  3. * All rights reserved.
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions are met:
  6. *
  7. * - Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * - Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. *
  13. * THIS SOFTWARE IS PROVIDED BY THE HAXE PROJECT CONTRIBUTORS "AS IS" AND ANY
  14. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. * DISCLAIMED. IN NO EVENT SHALL THE HAXE PROJECT CONTRIBUTORS BE LIABLE FOR
  17. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  19. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  20. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  21. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  22. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
  23. * DAMAGE.
  24. */
  25. package php;
  26. class PhpMath__
  27. {
  28. public static var PI;
  29. public static var NaN;
  30. public static var POSITIVE_INFINITY;
  31. public static var NEGATIVE_INFINITY;
  32. public static function abs(v) { return untyped __call__("abs", v); }
  33. public static function min(a,b) { return untyped __call__("min", a, b); }
  34. public static function max(a,b) { return untyped __call__("max", a, b); }
  35. public static function sin(v) { return untyped __call__("sin", v); }
  36. public static function cos(v) { return untyped __call__("cos", v); }
  37. public static function atan2(y,x) { return untyped __call__("atan2", y, x); }
  38. public static function tan(v) { return untyped __call__("tan", v); }
  39. public static function exp(v) { return untyped __call__("exp", v); }
  40. public static function log(v) { return untyped __call__("log", v); }
  41. public static function sqrt(v) { return untyped __call__("sqrt", v); }
  42. public static function round(v) { return untyped __call__("round", v); }
  43. public static function floor(v) { return untyped __call__("floor", v); }
  44. public static function ceil(v) { return untyped __call__("ceil", v); }
  45. public static function atan(v) { return untyped __call__("atan", v); }
  46. public static function asin(v) { return untyped __call__("asin", v); }
  47. public static function acos(v) { return untyped __call__("acos", v); }
  48. public static function pow(b,e) { return untyped __call__("pow", b, e); }
  49. public static function random() { return untyped __call__("mt_rand") / __call__("mt_getrandmax"); }
  50. public static function isNaN(f) { return untyped __call__("is_nan", f); }
  51. public static function isFinite(f) { return untyped __call__("is_finite", f); }
  52. static function __init__() {
  53. PI = untyped __php__("M_PI");
  54. NaN = untyped __php__("acos(1.01)");
  55. NEGATIVE_INFINITY = untyped __php__("log(0)");
  56. POSITIVE_INFINITY = -NEGATIVE_INFINITY;
  57. }
  58. }