Math Constants
Example
Section titled “Example”import * as mathConst from 'bg2e-js/ts/math/constants.ts';
console.log(mathConst.PI_4);Reference
Section titled “Reference”It is used in various parts of the graphics engine to label coordinate axes. It can also be used to obtain a text string with the axis name from its numeric value.
const xAxis = mathConst.Axis.X;const yAxis = mathConst.Axis.Y;const zAxis = mathConst.Axis.Z;console.log(`Axis: ${ mathConst.Axis.name(xAxis) }, ${ mathConst.Axis.name(yAxis) }, ${ mathConst.Axis.name(zAxis) }`);Numeric constants
Section titled “Numeric constants”mathConst.PI = π
mathConst.PI_2 = π / 2 (1.5707963267948966)
mathConst.PI_4 = π / 4 (0.785398163397448)
mathConst.PI_8 = π / 8 (0.392699081698724)
mathConst.TWO_PI = 2 * π (6.283185307179586)
mathConst.DEG_TO_RAD and mathConst.RAD_TO_DEG: you can use these constants to make conversions between degrees and radians:
const deg = 90;const rad = mathConst.PI_2;
console.log(`${deg}º = ${mathConst.DEG_TO_RAD * deg} radians.`);console.log(`${rad} radians = ${mathConst.RAD_TO_DEG * rad} degrees.`);mathConst.EPSILON = 0.0000001
mathConst.FLOAT_MAX = Maximum floating point 32 bits representable number (3.402823e38)
Array types
Section titled “Array types”mathConst.NumericArray: Default array type for high efficiency and low precision operations. By default is 32 bits. This type is used by all the array based objects in the graphic engine (vector, matrixes, etc.). The precision can be changed to 64 bits in configuration.
mathConst.NumericArrayHighP: Default array type for high precission operations. This type is implemented with a Float64Array type.