 B.Math

Contains linear algebra tools and commonly used geometry objects.

ENUMERATIONS:

Relation

A type of relation between two geometry objects.

{number} INTERSECT = 1

Two objects intersect each other.

{number} INSIDE = 2

The object is located inside another object.

{number} OUTSIDE = 4

The object is located outside another object.

CONSTANTS:

{number} EPSILON = 0.00000001

Negligibly small number.

FUNCTIONS:

equal(a, b)

Checks for strict equality of two numbers.

{number} a

{number} b

{number}

{number}

degrees

{number} degrees

RETURNS:

{number}

makeColor(r, g, b, a)

Makes a RGBA color.

PARAMETERS:

{number} [r] = 0

red component (value between 0 and 1)

{number} [g] = 0

green component (value between 0 and 1)

{number} [b] = 0

blue component (value between 0 and 1)

{number} [a] = 1

alpha component (value between 0 and 1)

RETURNS:

makeVector2(x, y)

Makes a 2D vector.

{number} [x] = 0

x component

{number} [y] = 0

y component

RETURNS:

makeVector3(x, y, z)

Makes a 3D vector.

{number} [x] = 0

x component

{number} [y] = 0

y component

{number} [z] = 0

z component

RETURNS:

makeVector4(x, y, z, w)

Makes a 4D vector.

{number} [x] = 0

x component

{number} [y] = 0

y component

{number} [z] = 0

z component

{number} [w] = 0

w component

RETURNS:

makeMatrix3(m00, m01, m02, m10, m11, m12, m20, m21, m22)

Makes a column-major 3x3 matrix.

PARAMETERS:

{number} [m00] = 1

{number} [m01] = 0

{number} [m02] = 0

{number} [m10] = 0

{number} [m11] = 1

{number} [m12] = 0

{number} [m20] = 0

{number} [m21] = 0

{number} [m22] = 1

RETURNS:

makeMatrix4(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33)

Makes a column-major 4x4 matrix.

PARAMETERS:

{number} [m00] = 1

{number} [m01] = 0

{number} [m02] = 0

{number} [m03] = 0

{number} [m10] = 0

{number} [m11] = 1

{number} [m12] = 0

{number} [m13] = 0

{number} [m20] = 0

{number} [m21] = 0

{number} [m22] = 1

{number} [m23] = 0

{number} [m30] = 0

{number} [m31] = 0

{number} [m32] = 0

{number} [m33] = 1

RETURNS:

makeQuaternion(w, x, y, z)

Makes a quaternion.

PARAMETERS:

{number} [w] = 1

w component (cos(angle/2))

{number} [x] = 0

x component (sin(angle/2)*axis.x)

{number} [y] = 0

y component (sin(angle/2)*axis.y)

{number} [z] = 0

z component (sin(angle/2)*axis.z)

RETURNS:

makeAngles(yaw, pitch, roll)

Makes canonical Euler angles (yaw-pitch-roll order).

PARAMETERS:

{number} [yaw] = 0

global Y-axis rotation [-PI, PI].

{number} [pitch] = 0

local X-axis rotation [-PI/2, PI/2].

{number} [roll] = 0

local Z-axis rotation [-PI, PI].

RETURNS:

makePlane(normal, distance)

Makes a plane.

PARAMETERS:

[normal] = B.Math.Vector3.Y

{number} [distance] = 0

RETURNS:

makeRay(origin, direction)

Makes a ray.

PARAMETERS:

[origin] = B.Math.Vector3.ZERO

[direction] = B.Math.Vector3.Z

RETURNS:

makeSegment(start, end)

Makes a segment.

RETURNS:

makeTriangle(a, b, c)

Makes a triangle.

RETURNS:

makeAABox(min, max)

Makes an axis-aligned box.

Makes a sphere.

PARAMETERS:

[center] = B.Math.Vector3.ZERO

RETURNS:

makeFrustum(left, right, top, bottom, near, far)

Makes a frustum.

PARAMETERS:

[left] = B.Math.Plane.X

[right] = B.Math.Plane.N_X

[top] = B.Math.Plane.N_Y

[bottom] = B.Math.Plane.Y

[near] = B.Math.Plane.N_Z

[far] = B.Math.Plane.Z