Wheel IDE

Online demo »

Math

This file contains a math functions.

Constants

The math module.
Source: lib/modules/math.whl, line: 9
MODULE_MATH1

Module calls for math functions.
Source: lib/modules/math.whl, line: 12
MATH_ROUND0
MATH_FLOOR1
MATH_CEIL2
MATH_ABS3
MATH_NEG4
MATH_RANDOM5
MATH_SIN6
MATH_COS7
MATH_TAN8
MATH_ASIN9
MATH_ACOS10
MATH_ATAN11
MATH_REMAINDER12
MATH_EXP13
MATH_SQRT14
MATH_LOG15
MATH_POW16
MATH_ODD17
MATH_EVEN18
MATH_IK_RAD19
MATH_IK_DEG20

Pi
Source: lib/modules/math.whl, line: 35
PI3.14159265359

Tau
Source: lib/modules/math.whl, line: 38
TAU6.283185307179586

Procedures

round
Source: lib/modules/math.whl, line: 53

Round a number.

proc round(number n)
Parameters:
NameTypeDescription
nnumberThe number to round.
Return: The rounded number.

Round a value to the closest integer value.

#include "lib/modules/standard.whl"
#include "lib/modules/math.whl"
#include "lib/modules/screen.whl"

proc main()
    number a
    number b

    a = 0.6
    ; b will be a rounded up to 1
    b = round(a)

    drawNumber(10, 10, a)
    drawNumber(10, 30, b)

    a = 2.4
    ; b will be a rounded down to 2
    b = round(a)
    drawNumber(10, 60, a)
    drawNumber(10, 80, b)
    halt()
end

floor
Source: lib/modules/math.whl, line: 61

Round a number down.

proc floor(number n)
Parameters:
NameTypeDescription
nnumberThe number to round down.
Return: The rounded number.

Round a value down to the closest integer value.

#include "lib/modules/standard.whl"
#include "lib/modules/math.whl"
#include "lib/modules/screen.whl"

proc main()
    number a
    number b

    a = 6.99
    ; b will be a rounded down to 6
    b = floor(a)

    drawNumber(10, 10, a)
    drawNumber(10, 30, b)

    a = -2.4
    ; b will be a rounded down to -3
    b = floor(a)
    drawNumber(10, 60, a)
    drawNumber(10, 80, b)
    halt()
end

ceil
Source: lib/modules/math.whl, line: 69

Round a number up.

proc ceil(number n)
Parameters:
NameTypeDescription
nnumberThe number to round up.
Return: The rounded number.

Round a value up to the closest integer value.

#include "lib/modules/standard.whl"
#include "lib/modules/math.whl"
#include "lib/modules/screen.whl"

proc main()
    number a
    number b

    a = 15.01
    ; b will be a rounded up to 16
    b = ceil(a)

    drawNumber(10, 10, a)
    drawNumber(10, 30, b)

    a = -19.4
    ; b will be a rounded up to -19
    b = ceil(a)
    drawNumber(10, 60, a)
    drawNumber(10, 80, b)
    halt()
end

abs
Source: lib/modules/math.whl, line: 77

Make a number positive.

proc abs(number n)
Parameters:
NameTypeDescription
nnumberThe number to make positive.
Return: The positive number.

Get the absolute value.

#include "lib/modules/standard.whl"
#include "lib/modules/math.whl"
#include "lib/modules/screen.whl"

proc main()
    number a
    number b

    a = -9
    ; b will be the positive value of a (9)
    b = abs(a)

    drawNumber(10, 10, a)
    drawNumber(10, 30, b)

    a = 67
    ; b will be the same value as a (67)
    b = abs(a)
    drawNumber(10, 60, a)
    drawNumber(10, 80, b)
    halt()
end

neg
Source: lib/modules/math.whl, line: 85

Make a number negative.

proc neg(number n)
Parameters:
NameTypeDescription
nnumberThe number to make negative.
Return: The negative number.

Get the negative value.

#include "lib/modules/standard.whl"
#include "lib/modules/math.whl"
#include "lib/modules/screen.whl"

proc main()
    number a
    number b

    a = -72
    ; b will be the positive value of a (72)
    b = neg(a)

    drawNumber(10, 10, a)
    drawNumber(10, 30, b)

    a = 13
    ; b will be the negative value of a (-13)
    b = neg(a)
    drawNumber(10, 60, a)
    drawNumber(10, 80, b)
    halt()
end

random
Source: lib/modules/math.whl, line: 93

Get a random number.

proc random(number min, number max)
Parameters:
NameTypeDescription
minnumberThe minimum value.
maxnumberThe maximum value, the random value is always less than the maximum value.
Return: A randum integer number.


sin
Source: lib/modules/math.whl, line: 103

Get the sine value for an angle in radians.

proc sin(number angle)
Parameters:
NameTypeDescription
anglenumberThe angle.
Return: The sine value.


cos
Source: lib/modules/math.whl, line: 111

Get the cosine value for an angle in radians.

proc cos(number angle)
Parameters:
NameTypeDescription
anglenumberThe angle.
Return: The cosine value.


tan
Source: lib/modules/math.whl, line: 119

Return tangent geometry value in radians.

proc tan(number value)
Parameters:
NameTypeDescription
valuenumberThe value.
Return: The tangent value.


asin
Source: lib/modules/math.whl, line: 127

Get the arcsine value for a value.

proc asin(number value)
Parameters:
NameTypeDescription
valuenumberThe value.
Return: The arcsine value in radians.


acos
Source: lib/modules/math.whl, line: 135

Get the arccosine value for a value.

proc acos(number value)
Parameters:
NameTypeDescription
valuenumberThe value.
Return: The arccosine value in radians.


atan
Source: lib/modules/math.whl, line: 143

Get the arctan value for a value.

proc atan(number value)
Parameters:
NameTypeDescription
valuenumberThe value.
Return: The arctan value in radians.


remainder
Source: lib/modules/math.whl, line: 151

Get the remainder (modulo) of a value.

proc remainder(number value, number remainder)
Parameters:
NameTypeDescription
valuenumberThe value.
remaindernumberThe remainder.
Return: The module value.


exp
Source: lib/modules/math.whl, line: 160

Get the exp value of a value.

proc exp(number value)
Parameters:
NameTypeDescription
valuenumberThe value.
Return: The exp value.


sqrt
Source: lib/modules/math.whl, line: 168

Get the square root value of a value.

proc sqrt(number value)
Parameters:
NameTypeDescription
valuenumberThe value.
Return: The square root value.


log
Source: lib/modules/math.whl, line: 176

Get the logarithm value of a value.

proc log(number value)
Parameters:
NameTypeDescription
valuenumberThe value.
Return: The logarithm value.


pow
Source: lib/modules/math.whl, line: 184

Get base to the exponent power.

proc pow(number base, number exponent)
Parameters:
NameTypeDescription
basenumberThe base value.
exponentnumberThe exponent value.
Return: The base to the exponent value.


odd
Source: lib/modules/math.whl, line: 193

Check if a number is odd.

proc odd(number value)
Parameters:
NameTypeDescription
valuenumberThe value to check.
Return: Return 1 if odd, 0 if even.


even
Source: lib/modules/math.whl, line: 201

Check if a number is even.

proc even(number value)
Parameters:
NameTypeDescription
valuenumberThe value to check.
Return: Return 1 if even, 0 if odd.


ikRad
Source: lib/modules/math.whl, line: 209

Calculate the inverse kinimatic angles in radians based on the `ikData` record. This procedure is only supported in the IDE.

proc ikRad()

ikDeg
Source: lib/modules/math.whl, line: 216

Calculate the inverse kinimatic angles in degrees based on the `ikData` record. This procedure is only supported in the IDE.

proc ikDeg()