Namespace: math

og.math

Classes

Matrix3
Matrix4
Pixel
Quaternion
Ray
Vector2
Vector3
Vector4

Namespaces

coder

Members

static,constantog.math.ARCSECONDS_TO_RADIANS

static,constantog.math.DEGREES

static,constantog.math.DEGREES_DOUBLE

static,constantog.math.DEGREES_TO_HOURS

static,constantog.math.HOURS_TO_DEGREES

static,constantog.math.HOURS_TO_RADIANS

static,constantog.math.LOG2

static,constantog.math.MAX

static,constantog.math.MAX32

static,constantog.math.MIN

static,constantog.math.PI_TWO

static,constantog.math.RADIANS

static,constantog.math.RADIANS_HALF

static,constantog.math.RADIANS_TO_HOURS

static,constantog.math.SQRT_HALF

static,constantog.math.TWO_PI

Methods

staticog.math.bezier(t, p0, p1, p2, p3){og.math.Vector3}

Performs a 3D bezier interpolation.
Name Type Description
t number
p0 og.math.Vector3 First control point.
p1 og.math.Vector3 Second control point.
p2 og.math.Vector3 Third control point.
p3 og.math.Vector3 Fourth control point.
Returns:
Type Description
og.math.Vector3

staticog.math.clamp(number, min, max){number}

Clamp the number.
Name Type Description
number number Input number.
min number Minimal edge.
max number Maximal edge.
Returns:
Type Description
number
Example
og.math.clamp(12,1,5)
//returns 5

staticog.math.DEG2RAD(degrees){number}

Converts degrees value to radians.
Name Type Description
degrees number Degree value.
Returns:
Type Description
number

staticog.math.degToDec(d, m, s, p)

Converts degrees value to decimal.
Name Type Description
d number Degrees.
m number Minutes.
s number Seconds.
p boolean optional Positive flag. False - default.

staticog.math.exp2(n){number}

Returns two power of n.
Name Type Description
n number Power value.
Returns:
Type Description
number

staticog.math.frac(x){number}

The fract function returns the fractional part of x, i.e. x minus floor(x).
Name Type Description
x number Input value.
Returns:
Type Description
number

staticog.math.isPowerOfTwo(x){boolean}

Check the number is a power of two.
Name Type Description
x number Value.
Returns:
Type Description
boolean

staticog.math.lerp(t, h1, h1){number}

Performs a linear interpolation.
Name Type Description
t number A value that linearly interpolates between the x parameter and the y parameter.
h1 number The first value.
h1 number The second value.
Returns:
Type Description
number

staticog.math.log(n, base){number}

The log function returns the power to which the base value has to be raised to produce n.
Name Type Description
n number Produce value.
base number Base value.
Returns:
Type Description
number
Example
og.math.log(64,2)
//returns 6

staticog.math.log2(x){number}

Returns Math.log(x) / Math.log(2)
Name Type Description
x number
Returns:
Type Description
number

staticog.math.matrix3(){og.math.Matrix3}

Matrix3 factory.
Returns:
Type Description
og.math.Matrix3

staticog.math.matrix4(){og.math.Matrix4}

Matrix4 factory.
Returns:
Type Description
og.math.Matrix4

staticog.math.mod(m, n){number}

The modulo operation that also works for negative dividends.
Name Type Description
m number The dividend.
n number The divisor.
Returns:
Type Description
number The remainder.

staticog.math.negativePItoPI(a){number}

Returns an angle in the range -Pi <= angle <= Pi which is equivalent to the provided angle.
Name Type Description
a number Angle in radians
Returns:
Type Description
number

staticog.math.nextHighestPowerOfTwo(x){number}

Returns next value that is power of two.
Name Type Description
x number Value.
Returns:
Type Description
number

staticog.math.norm_lon(lon){number}

Clamp longitude within: -180 to +180 degrees.
Name Type Description
lon number Longitude.
Returns:
Type Description
number

staticog.math.pow2i(n){number}

Returns two power of integer n.
Name Type Description
n number Integer power value.
Returns:
Type Description
number

staticog.math.quaternion(x, y, z, w){og.math.Quaternion}

Creates quaternion instance.
Name Type Default Description
x Number 0.0 optional The X component.
y Number 0.0 optional The Y component.
z Number 0.0 optional The Z component.
w Number 0.0 optional The W component.
Returns:
Type Description
og.math.Quaternion

staticog.math.RAD2DEG(angle){number}

Converts radians value to degrees.
Name Type Description
angle number Degree value.
Returns:
Type Description
number

staticog.math.random(min, max){number}

Returns random number within the bounds.
Name Type Description
min number Minimal bound.
max number Maximal bound.
Returns:
Type Description
number

staticog.math.randomi(min, max){number}

Returns random integer number within the bounds.
Name Type Description
min number Minimal bound.
max number Maximal bound.
Returns:
Type Description
number

staticog.math.ray(origin, direction){og.math.Ray}

Ray object creator.
Name Type Description
origin og.math.Vector3 The origin of the ray.
direction og.math.Vector3 The direction of the ray.
Returns:
Type Description
og.math.Ray

staticog.math.rev(x){number}

Clamp angle value within 360.
Name Type Description
x number Input angle.
Returns:
Type Description
number

staticog.math.slice(t, h1, h0){number}

Returns a slice of linear interpolation t * (h1 - h0)
Name Type Description
t number
h1 number
h0 number
Returns:
Type Description
number

staticog.math.solve_iteration(f, x0, err, maxIter){number}

Solve using iteration; terminate when error is below err or the maximum number of iterations is reached. Used in Euler's equation(see og.orbit) solving.
Name Type Description
f equationCallback Equation.
x0 number First approximation.
err number Maximal accepted error value.
maxIter number Maximum iterations.
Returns:
Type Description
number

staticog.math.solve_iteration_fixed(f, x0, maxIter){number}

Solve using iteration method and a fixed number of steps.
Name Type Description
f equationCallback Equation. Used in Euler's equation(see og.orbit) solving.
x0 number First approximation.
maxIter number Maximum iterations.
Returns:
Type Description
number

staticog.math.step(edge, x){number}

Returns 0.0 if x is smaller then edge and otherwise 1.0.
Name Type Description
edge number Edge.
x number Value to edge.
Returns:
Type Description
number

staticog.math.vector2(x, y){og.math.Vector2}

Vector 2d object creator.
Name Type Description
x number optional First cvalue.
y number optional Second value.
Returns:
Type Description
og.math.Vector2

staticog.math.vector3(x, y, z){og.math.Vector3}

Vector 3d object creator.
Name Type Description
x number optional First cvalue.
y number optional Second value.
z number optional Third value.
Returns:
Type Description
og.math.Vector3

staticog.math.vector4(x, y, z, w){og.math.Vector4}

Vector 4d object creator.
Name Type Description
x number optional First cvalue.
y number optional Second value.
z number optional Third value.
w number optional Fourth value.
Returns:
Type Description
og.math.Vector4

staticog.math.zeroTwoPI(a){number}

Returns an angle in the range 0 <= angle <= 2Pi which is equivalent to the provided angle.
Name Type Description
a number Angle in radians
Returns:
Type Description
number