Header menu logo Euclid

UtilEuclid Module

Math Utility functions and values for use within Euclid.

Functions and values

Function or value Description

``-1.0+1e-6``

Full Usage: ``-1.0+1e-6``

Returns: float

The float number that is 9 increments smaller than -1.0. This is approx -1.0 + 1e-6 see https://float.exposed/0xbf800009

Returns: float

``-1.0-1e-6``

Full Usage: ``-1.0-1e-6``

Returns: float

The float number that is 16 increments bigger than 1.0. This is approx 1.0 - 1e-6 see https://float.exposed/0xbf7ffff0

Returns: float

``1.0+1e-6``

Full Usage: ``1.0+1e-6``

Returns: float

The float number that is 9 increments bigger than 1.0. This is approx 1.0 + 1e-6 see https://float.exposed/0x3f800009

Returns: float

``1.0-1e-6``

Full Usage: ``1.0-1e-6``

Returns: float

The float number that is 16 increments smaller than 1.0. This is approx 1.0 - 1e-6 see https://float.exposed/0x3f7ffff0

Returns: float

acosSafe a

Full Usage: acosSafe a

Parameters:
    a : float

Returns: float
Modifiers: inline

A safe arccosine (Inverse Cosine) function. It clamps the input between -1 and 1

a : float
Returns: float

asinSafe a

Full Usage: asinSafe a

Parameters:
    a : float

Returns: float
Modifiers: inline

A safe arcsine (Inverse Sine) function. It clamps the input between -1 and 1

a : float
Returns: float

clampBetweenMinusOneAndOne x

Full Usage: clampBetweenMinusOneAndOne x

Parameters:
    x : float

Returns: float
Modifiers: inline

Clamp value between -1.0 and +1.0

x : float
Returns: float

clampBetweenZeroAndOne x

Full Usage: clampBetweenZeroAndOne x

Parameters:
    x : float

Returns: float
Modifiers: inline

Clamp value between 0.0 and +1.0

x : float
Returns: float

halfPi

Full Usage: halfPi

Returns: float

Math.PI * 0.5 This is equal to 90 degrees in radians.

Returns: float

isBetweenZeroAndOne x

Full Usage: isBetweenZeroAndOne x

Parameters:
    x : float

Returns: bool
Modifiers: inline

Check if value is between 0.0 and +1.0 inclusive.

x : float
Returns: bool

isBetweenZeroAndOneTolerant x

Full Usage: isBetweenZeroAndOneTolerant x

Parameters:
    x : float

Returns: bool
Modifiers: inline

Check if value is between 0.0 and +1.0 inclusive a tolerance of 1e-6 .

x : float
Returns: bool

isMinusOne x

Full Usage: isMinusOne x

Parameters:
    x : float

Returns: bool
Modifiers: inline

Tests if a number is close to minus 1.0 by a 1e-6 tolerance. This is a float increment of 6 steps or decrement of 16 steps.

x : float
Returns: bool

isNegative x

Full Usage: isNegative x

Parameters:
    x : float

Returns: bool
Modifiers: inline

Returns true for negative number and for NaN 0.0 and -0.0 is not negative.

x : float
Returns: bool

isNotOne x

Full Usage: isNotOne x

Parameters:
    x : float

Returns: bool
Modifiers: inline

Tests if a number is NOT close to 1.0 by a 1e-6 tolerance. This is a float increment of 6 steps or decrement of 16 steps. Also returns true for NaN.

x : float
Returns: bool

isNotZero x

Full Usage: isNotZero x

Parameters:
    x : float

Returns: bool
Modifiers: inline

Tests if a number is NOT close to 0.0 by 1e-6 This is approximately the same tolerance that 6 increments of a float are away from 1.0. See Euclid.UtilEuclid.isOne function. Also returns true for NaN.

x : float
Returns: bool

isOne x

Full Usage: isOne x

Parameters:
    x : float

Returns: bool
Modifiers: inline

Tests if a number is close to 1.0 by a 1e-6 tolerance. This is a float increment of 6 steps or decrement of 16 steps.

x : float
Returns: bool

isTooSmall x

Full Usage: isTooSmall x

Parameters:
    x : float

Returns: bool
Modifiers: inline

Returns true for values smaller than 1e-6 and for NaN

x : float
Returns: bool

isTooSmallSq x

Full Usage: isTooSmallSq x

Parameters:
    x : float

Returns: bool
Modifiers: inline

Returns true for values smaller than 1e-12 (square of 1e-6) and for NaN

x : float
Returns: bool

isTooTiny x

Full Usage: isTooTiny x

Parameters:
    x : float

Returns: bool
Modifiers: inline

Returns true for values smaller than 1e-12 and for NaN uses UtilEuclid.zeroLengthTolerance

x : float
Returns: bool

isTooTinySq x

Full Usage: isTooTinySq x

Parameters:
    x : float

Returns: bool
Modifiers: inline

Returns true for values smaller than 1e-24 (square of 1e-12) and for NaN uses UtilEuclid.zeroLengthTolSquared

x : float
Returns: bool

isZero x

Full Usage: isZero x

Parameters:
    x : float

Returns: bool
Modifiers: inline

Tests if a number is close to 0.0 by 1e-6 This is approximately the same tolerance that 6 increments of a float are away from 1.0. See Euclid.UtilEuclid.isOne function.

x : float
Returns: bool

matchSign signedValue numToMatch

Full Usage: matchSign signedValue numToMatch

Parameters:
    signedValue : float
    numToMatch : float

Returns: float

Match the sign (+ or -) to a given number.

signedValue : float
numToMatch : float
Returns: float

notNull x

Full Usage: notNull x

Parameters:
    x : 'a

Returns: bool
Modifiers: inline
Type parameters: 'a

Test is a value is not null.

x : 'a
Returns: bool

saveIdx i length

Full Usage: saveIdx i length

Parameters:
    i : int
    length : int

Returns: int
Modifiers: inline

Any int will give a valid index for given collection size. Converts negative indices to positive ones and loops to start after last index is reached. Returns a valid index for a collection of 'length' items for any integer.

i : int
length : int
Returns: int

toDegrees radians

Full Usage: toDegrees radians

Parameters:
    radians : float

Returns: float
Modifiers: inline

Converts Angels from Radians to Degrees. By multiplying with 57.29... (180. / PI)

radians : float
Returns: float

toRadians degrees

Full Usage: toRadians degrees

Parameters:
    degrees : float

Returns: float
Modifiers: inline

Converts Angels from Degrees to Radians. By multiplying with 0.0174... (PI / 180.)

degrees : float
Returns: float

twoPi

Full Usage: twoPi

Returns: float

Math.PI * 2.0 This is equal to 360 degrees in radians.

Returns: float

zeroLengthTolerance

Full Usage: zeroLengthTolerance

Returns: float

Tolerance for zero length: 1e-12 in divisions and unitizing of vectors.

Returns: float

Type something to start searching.