class Math

class Math

lib/math.tya:2

Math provides numeric constants and common math functions.

Source
# Math provides numeric constants and common math functions.
class Math
  # E is Euler's number, the base of natural logarithms.
  # @type Float
  E: 2.718281828459045

  # PI is the ratio of a circle circumference to its diameter.
  # @type Float
  PI: 3.141592653589793

  # abs returns the absolute value of a number.
  # @param value String value value.
  # @return Any the resulting value.
  abs: value ->
    if value < 0
      return 0 - value
    value

  # Math.acos provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  acos: x ->
    math_acos(x)

  # Math.asin provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  asin: x ->
    math_asin(x)

  # Math.atan provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  atan: x ->
    math_atan(x)

  # Math.atan2 provides the math/Math standard library operation.
  # @param y Int y value.
  # @param x Int x value.
  # @return Any the resulting value.
  atan2: y, x ->
    math_atan2(y, x)

  # Math.ceil provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  ceil: x ->
    math_ceil(x)

  # clamp constrains value to the inclusive lo..hi range.
  # Raises when lo is greater than hi.
  # @param value String value value.
  # @param lo Any lo value.
  # @param hi Any hi value.
  # @return Any the resulting value.
  clamp: value, lo, hi ->
    if lo > hi
      raise error("math.clamp: min must be less than or equal to max")
    if value < lo
      return lo
    if value > hi
      return hi
    value

  # Math.cos provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  cos: x ->
    math_cos(x)

  # Math.exp provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  exp: x ->
    math_exp(x)

  # Math.floor provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  floor: x ->
    math_floor(x)

  # Math.log provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  log: x ->
    math_log(x)

  # Math.log10 provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  log10: x ->
    math_log10(x)

  # Math.log2 provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  log2: x ->
    math_log2(x)

  # Math.max provides the math/Math standard library operation.
  # @param left Any left value.
  # @param right Any right value.
  # @return Any the resulting value.
  max: left, right ->
    if left > right
      return left
    right

  # Math.min provides the math/Math standard library operation.
  # @param left Any left value.
  # @param right Any right value.
  # @return Any the resulting value.
  min: left, right ->
    if left < right
      return left
    right

  # Math.pow provides the math/Math standard library operation.
  # @param x Int x value.
  # @param y Int y value.
  # @return Any the resulting value.
  pow: x, y ->
    math_pow(x, y)

  # Math.round provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  round: x ->
    math_round(x)

  # Math.sin provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  sin: x ->
    math_sin(x)

  # Math.sqrt provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  sqrt: x ->
    math_sqrt(x)

  # Math.tan provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  tan: x ->
    math_tan(x)

  # Math.trunc provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  trunc: x ->
    math_trunc(x)

Class Constants

E

Math.E

lib/math.tya:5

E is Euler's number, the base of natural logarithms.

Source
  # E is Euler's number, the base of natural logarithms.
  # @type Float
  E: 2.718281828459045

PI

Math.PI

lib/math.tya:9

PI is the ratio of a circle circumference to its diameter.

Source
  # PI is the ratio of a circle circumference to its diameter.
  # @type Float
  PI: 3.141592653589793

Methods

abs

Math.abs(value)

lib/math.tya:14

abs returns the absolute value of a number.

Source
  # abs returns the absolute value of a number.
  # @param value String value value.
  # @return Any the resulting value.
  abs: value ->
    if value < 0
      return 0 - value
    value

acos

Math.acos(x)

lib/math.tya:22

Math.acos provides the math/Math standard library operation.

Source
  # Math.acos provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  acos: x ->
    math_acos(x)

asin

Math.asin(x)

lib/math.tya:28

Math.asin provides the math/Math standard library operation.

Source
  # Math.asin provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  asin: x ->
    math_asin(x)

atan

Math.atan(x)

lib/math.tya:34

Math.atan provides the math/Math standard library operation.

Source
  # Math.atan provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  atan: x ->
    math_atan(x)

atan2

Math.atan2(y, x)

lib/math.tya:41

Math.atan2 provides the math/Math standard library operation.

Source
  # Math.atan2 provides the math/Math standard library operation.
  # @param y Int y value.
  # @param x Int x value.
  # @return Any the resulting value.
  atan2: y, x ->
    math_atan2(y, x)

ceil

Math.ceil(x)

lib/math.tya:47

Math.ceil provides the math/Math standard library operation.

Source
  # Math.ceil provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  ceil: x ->
    math_ceil(x)

clamp

Math.clamp(value, lo, hi)

lib/math.tya:56

clamp constrains value to the inclusive lo..hi range. Raises when lo is greater than hi.

Source
  # clamp constrains value to the inclusive lo..hi range.
  # Raises when lo is greater than hi.
  # @param value String value value.
  # @param lo Any lo value.
  # @param hi Any hi value.
  # @return Any the resulting value.
  clamp: value, lo, hi ->
    if lo > hi
      raise error("math.clamp: min must be less than or equal to max")
    if value < lo
      return lo
    if value > hi
      return hi
    value

cos

Math.cos(x)

lib/math.tya:68

Math.cos provides the math/Math standard library operation.

Source
  # Math.cos provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  cos: x ->
    math_cos(x)

exp

Math.exp(x)

lib/math.tya:74

Math.exp provides the math/Math standard library operation.

Source
  # Math.exp provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  exp: x ->
    math_exp(x)

floor

Math.floor(x)

lib/math.tya:80

Math.floor provides the math/Math standard library operation.

Source
  # Math.floor provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  floor: x ->
    math_floor(x)

log

Math.log(x)

lib/math.tya:86

Math.log provides the math/Math standard library operation.

Source
  # Math.log provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  log: x ->
    math_log(x)

log10

Math.log10(x)

lib/math.tya:92

Math.log10 provides the math/Math standard library operation.

Source
  # Math.log10 provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  log10: x ->
    math_log10(x)

log2

Math.log2(x)

lib/math.tya:98

Math.log2 provides the math/Math standard library operation.

Source
  # Math.log2 provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  log2: x ->
    math_log2(x)

max

Math.max(left, right)

lib/math.tya:105

Math.max provides the math/Math standard library operation.

Source
  # Math.max provides the math/Math standard library operation.
  # @param left Any left value.
  # @param right Any right value.
  # @return Any the resulting value.
  max: left, right ->
    if left > right
      return left
    right

min

Math.min(left, right)

lib/math.tya:114

Math.min provides the math/Math standard library operation.

Source
  # Math.min provides the math/Math standard library operation.
  # @param left Any left value.
  # @param right Any right value.
  # @return Any the resulting value.
  min: left, right ->
    if left < right
      return left
    right

pow

Math.pow(x, y)

lib/math.tya:123

Math.pow provides the math/Math standard library operation.

Source
  # Math.pow provides the math/Math standard library operation.
  # @param x Int x value.
  # @param y Int y value.
  # @return Any the resulting value.
  pow: x, y ->
    math_pow(x, y)

round

Math.round(x)

lib/math.tya:129

Math.round provides the math/Math standard library operation.

Source
  # Math.round provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  round: x ->
    math_round(x)

sin

Math.sin(x)

lib/math.tya:135

Math.sin provides the math/Math standard library operation.

Source
  # Math.sin provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  sin: x ->
    math_sin(x)

sqrt

Math.sqrt(x)

lib/math.tya:141

Math.sqrt provides the math/Math standard library operation.

Source
  # Math.sqrt provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  sqrt: x ->
    math_sqrt(x)

tan

Math.tan(x)

lib/math.tya:147

Math.tan provides the math/Math standard library operation.

Source
  # Math.tan provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  tan: x ->
    math_tan(x)

trunc

Math.trunc(x)

lib/math.tya:153

Math.trunc provides the math/Math standard library operation.

Source
  # Math.trunc provides the math/Math standard library operation.
  # @param x Int x value.
  # @return Any the resulting value.
  trunc: x ->
    math_trunc(x)