lowdefy/packages/docs/operators/_math.yaml
2021-02-11 19:09:10 +02:00

375 lines
14 KiB
YAML

# Copyright 2020-2021 Lowdefy, Inc
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
_ref:
path: templates/operators.yaml.njk
transformer: templates/operatorsMethodTransformer.js
vars:
pageId: _math
pageTitle: _math
filePath: operators/_math.yaml
description: |
The `_math` operator can be used to run javascript [`Math`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math) methods.
The `_math` operator can take arguments in the following forms:
###### No Arguments
```text
(void): number
```
Some methods like `_math.PI` take no arguments:
```yaml
_math.PI: null
```
Returns: `pi`
###### Single argument
```text
(x: number): number
```
Some methods like `_math.round` take a single argument:
```yaml
_math.round: 3.14
```
Returns: `3`
###### Named arguments
```text
({x: number, y: number}): number
([x: number, y: number]): number
```
Some methods like `_math.pow` take an object with named arguments:
```yaml
_math.pow:
base: 2
exponent: 3
```
Returns: `8`
These methods also accept their arguments as an array:
```yaml
_math.pow:
- 2
- 3
```
Returns: `8`
###### Array arguments
```text
(values: number[]): number
```
Some methods like `_math.max` take an array of values as arguments:
```
_math.max:
- 42
- 99
- 0
```
Returns: `99`
methods:
- name: abs
types: |
```
(x: number): number
```
description: |
The `_math.abs` method returns the [absolute value](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/abs) of a number.
- name: acos
types: |
```
(x: number): number
```
description: |
The `_math.acos` method returns the [arccosine](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acos) (in radians) of a number.
- name: acosh
types: |
```
(x: number): number
```
description: |
The `_math.acosh` method returns the [hyperbolic arc-cosine](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/acosh) of a number.
- name: asin
types: |
```
(x: number): number
```
description: |
The `_math.asin` method returns the [arcsine](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/asin) (in radians) of a number.
- name: atan
types: |
```
(x: number): number
```
description: |
The `_math.atan` method returns the [arctangent](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan) (in radians) of a number.
- name: atan2
types: |
```
({x: number, y: number}): number
([x: number, y: number]): number
```
description: |
The `_math.atan2` method returns the [angle in the plane (in radians) between the positive x-axis and the ray from (0,0) to the point (x,y)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2).
- name: atanh
types: |
```
(x: number): number
```
description: |
The `_math.atanh` method returns the [hyperbolic arctangent](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atanh) of a number.
- name: cbrt
types: |
```
(x: number): number
```
description: |
The `_math.cbrt` method returns the returns the [cube root](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cbrt) of a number.
- name: ceil
types: |
```
(x: number): number
```
description: |
The `_math.ceil` method [rounds a number up](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/ceil) to the next largest integer.
- name: clz32
types: |
```
(x: number): number
```
description: |
The `_math.clz32` method returns the [number of leading zero bits in the 32-bit binary representation of a number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32).
- name: cos
types: |
```
(x: number): number
```
description: |
The `_math.cos` method returns the [cosine](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cos) of the specified angle, which must be specified in radians
- name: cosh
types: |
```
(x: number): number
```
description: |
The `_math.cosh` method returns the [hyperbolic cosine](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh) of a number.
- name: exp
types: |
```
(x: number): number
```
description: |
The `_math.exp` method returns [`e` (Euler's number) to the power `x`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/exp).
- name: expm1
types: |
```
(x: number): number
```
description: |
The `_math.expm1` method returns [`e` (Euler's number) to the power `x` minus `1`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/expm1).
- name: floor
types: |
```
(x: number): number
```
description: |
The `_math.floor` method returns the [largest integer less than or equal to a given number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/floor).
- name: fround
types: |
```
(x: number): number
```
description: |
The `_math.fround` method returns the [nearest 32-bit single precision float representation of a number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/fround).
- name: hypot
types: |
```
(values: number[]): number
```
description: |
The `_math.hypot` method returns the [square root of the sum of squares of its arguments](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/hypot).
- name: imul
types: |
```
({a: number, b: number}): number
([a: number, b: number]): number
```
description: |
The `_math.imul` method returns the [result of the C-like 32-bit multiplication of the two parameters](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul).
- name: log
types: |
```
(x: number): number
```
description: |
The `_math.log` method returns the [natural logarithm](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log) (base `e`) of a number.
- name: log10
types: |
```
(x: number): number
```
description: |
The `_math.log10` method returns the [base `10` logarithm](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log10) of a number.
- name: log1p
types: |
```
(x: number): number
```
description: |
The `_math.log1p` method returns the [natural logarithm (base e) of `1 + a number`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log1p).
- name: log2
types: |
```
(x: number): number
```
description: |
The `_math.log2` method returns the [base `2` logarithm](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/log2) of a number.
- name: max
types: |
```
(values: number[]): number
```
description: |
The `_math.max` method returns the [largest of the numbers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) given as input parameters.
- name: min
types: |
```
(values: number[]): number
```
description: |
The `_math.min` method returns the [smallest of the numbers](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/max) given as input parameters.
- name: pow
types: |
```
({base: number, exponent: number}): number
([base: number, exponent: number]): number
```
description: |
The `_math.pow` method returns the [`base` to the `exponent` power](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/pow).
- name: random
types: |
```
(void): number
```
description: |
The `_math.random` method returns a floating-point, [pseudo-random number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random) in the range `0` to less than `1`.
- name: round
types: |
```
(x: number): number
```
description: |
The `_math.round` method returns the value of a number [rounded to the nearest integer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round).
- name: sign
types: |
```
(x: number): number
```
description: |
The `_math.sign` method returns either a [positive or negative 1 (`+/- 1`)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign), indicating the sign of a number passed into the argument.
- name: sin
types: |
```
(x: number): number
```
description: |
The `_math.sin` method returns the [sine](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sin) of a number.
- name: sinh
types: |
```
(x: number): number
```
description: |
The `_math.sinh` method returns the [hyperbolic sine](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sinh) of a number.
- name: sqrt
types: |
```
(x: number): number
```
description: |
The `_math.sqrt` method returns the [square root](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sqrt) of a number.
- name: tan
types: |
```
(x: number): number
```
description: |
The `_math.tan` method returns the [tangent](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/tan) of a number.
- name: trunc
types: |
```
(x: number): number
```
description: |
The `_math.trunc` method returns the [integer part](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/trunc) of a number by removing any fractional digits.
- name: E
types: |
```
(void): number
```
description: |
The `_math.E` method returns [Euler's number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/E), the base of natural logarithms, `e`, which is approximately 2.718.
- name: LN10
types: |
```
(void): number
```
description: |
The `_math.LN10` method returns the [natural logarithm of `10`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN10), which is approximately 2.302.
- name: LN2
types: |
```
(void): number
```
description: |
The `_math.LN2` method returns the [natural logarithm of `2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LN2), which is approximately 0.693.
- name: LOG10E
types: |
```
(void): number
```
description: |
The `_math.LOG10E` method returns the [base `10` logarithm of `e`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG10E), which is approximately 0.434.
- name: LOG2E
types: |
```
(void): number
```
description: |
The `_math.LOG2E` method returns the [base `2` logarithm of `e`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/LOG2E), which is approximately 1.442.
- name: PI
types: |
```
(void): number
```
description: |
The `_math.PI` method returns the constant [`pi`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/PI), the ratio of the circumference of a circle to its diameter, which is approximately 3.14159.
- name: SQRT1_2
types: |
```
(void): number
```
description: |
The `_math.SQRT1_2` method returns the [square root of `1/2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT1_2), which is approximately 0.707.
- name: SQRT2
types: |
```
(void): number
```
description: |
The `_math.SQRT2` method returns the [square root of `2`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/SQRT2), which is approximately 1.414.