Added math documentation

This commit is contained in:
Add00
2023-08-02 22:04:08 -04:00
parent 74309439e7
commit d6565febce

129
getting-started/math.md Normal file
View File

@@ -0,0 +1,129 @@
# Math Library
The math library is a collection of mathematical functions and constants that provide a wide range of calculations that are commonly used.
All functions in this library take floats or integers as parameters and will return the result as a float.
The math library can be through the `import` keyword:
```
import math;
```
## Constants
### PI: float
Represents the ratio of a circle's circumference to its diameter.
### E: float
Represents Euler's number, the base of natural logarithms.
### EPSILON: float
Represents the acceptable amount of approximation for floats, defaults to `0.000001`.
### NAN: float
Represents Not-a-Number, often returned when a calculation is impossible e.g. `sqrt(-1)`
### INFINITY: float
Represents the largest possible float type.
## Power
### pow(x, y): float
Returns `x` to the power of `y`.
### sqrt(x): float
Returns the square root of `x`.
### qbrt(x): float
Returns the cube root of `x`.
### hypot(x, y): float
Returns the length of the hypotenuse assuming `x` and `y` are the legs in a right-angle triangle.
## Trigonometric
## toRadians(d): float
Converts `d` into radians.
## toDegrees(r): float
Converts `r` into degrees.
## sin(x): float
Returns the sine of `x`.
## cos(x): float
Returns the cosine of `x`.
## tan(x): float
Returns the tangent of `x`.
## asin(x): float
Returns the arc sine of `x`.
## acos(x): float
Returns the arc cosine of `x`.
## atan(x): float
Returns the arc tangent of `x`.
## Hyperbolic
## sinh(x): float
Returns the hyperbolic sine of `x`
## cosh(x): float
Returns the hyperbolic cosine of `x`
## tanh(x): float
Returns the hyperbolic tangent of `x`
## asinh(x): float
Returns the inverse hyperbolic sine of `x`
## acosh(x): float
Returns the inverse cosine sine of `x`
## atanh(x): float
Returns the inverse tangent sine of `x`
## Comparison
### checkIsNaN(x): bool
Returns true if `x` is NaN and false otherwise.
### chechIsFinite(x): bool
Returns true if `x` is finite or in otherwords it is not Infinite or NaN.
### chechIsInfinite(x): bool
Returns true if `x` is Infinite and false otherwise.
### epsilionCompare(x, y): bool
Returns true if `x` or `y` are within epsilon of each other, otherwise it returns false. This is very useful for compairing floating point values.