Skip to content
Stephen K edited this page Apr 7, 2014 · 3 revisions

setTolerance(t)

Set the tolerance of the math library

Parameters

t: Number, The new tolerance

getNoIntersection()

Find out what the no intersection constant is

Returns

Number, The constant representing that there was no intersection

getTolerance()

Get the tolerance of the math library

Returns

Number, The current tolerance

Vect(x, y, z, w)

Create a Vect

Parameters

x: Number, The x coordinate

y: Number, The y coordinate

z: Number, The z coordinate

w: Number, The homogeneous component

toString()

Converts this object to string format

Returns

String, The string representation of the Vect

Ray(o, dir)

Create a Ray to cast

Parameters

o: Vect, Origin of Ray

dir: Vect, Direction of Ray

toString()

Convert Ray to string

Returns

String, The string representation of the Ray

getPoint(t)

Get a point along the ray

Parameters

t: Number, The position along the line to retrieve

Returns

Vect, The point at position t

Triangle(a, b, c)

Create a Triangle

Parameters

a: Vect, The first point in the triangle

b: Vect, The second point in the triangle

c: Vect, The third point in the triangle

toString()

Get the string representation of this Triangle

Returns

String, The string representation of this Triangle

Sphere(c, r)

Creates a Sphere

Parameters

c: Vect, The center of the Sphere

r: Number, The radius of the Sphere

toString()

Get the string representation of this sphere

Returns

String, String representation of the Sphere

CollisionRecord(point, normal)

A record of a collision between objects

Parameters

point: Vect, The position at which the collision occured

normal: Vect, The collision normal

Viewport(width, height, top, bottom, left, right, near, far, fov)

Viewport constructor

Parameters

width: type,

height: type,

top: type,

bottom: type,

left: type,

right: type,

near: type,

far: type,

fov: type,

cross(v0, v1)

Get cross product of two vectors

Parameters

v0: Vect, The first vector of the cross operation

v1: Vect, the second vector of the cross operation

Returns

Vect, The result of the cross operation

dot(v0, v1)

Find dot product of two vectors

Parameters

v0: Vect, The first vector of the dot product operation

v1: Vect, The second vector of the dot product operation

Returns

Number, The result of the dot product operation

normalize(v)

Normalize a vector

Parameters

v: Vect, The vector to normalize

Returns

Vect, The normalized vector

magnitude(v)

Get the magnitude of a vector

Parameters

v: Vect, The vector to get the magnitude of

Returns

Number, The magnitude of the vector

projection(v1, v2)

Find the projection of one vector onto another

Parameters

v1: Vect, The first vector of the projection operation

v2: Vect, The second vector of the projection operation

Returns

Vect, The result of the projection operation

scale(v0, s)

Scale a Vect by a scalar

Parameters

v0: Vect, The vector to scale

s: Number, The scalar to scale the vector by

Returns

Vect, The scaled vector

add(v0, v1)

Add one Vect to another

Parameters

v0: Vect, The first addend vector

v1: Vect, The second addend vector

Returns

Vect, The sum of the vectors

subtract(v0, v1)

Return the difference between two vects

Parameters

v0: Vect, The minuend vector

v1: Vect, The subtrahend vector

Returns

Vect, The difference vector

multiply(v0, v1)

Multiply one vect by another

Parameters

v0: Vect, The multiplicand vector

v1: Vect, The multiplier vector

Returns

Vect, The product vector

divide(v0, v1)

Divide a Vect by another

Parameters

v0: Vect, The dividend vector

v1: Vect, The divisor vector

Returns

Vect, The quotient vector

equalityVect(v0, v1)

Check that two Vect are equal within tolerance

Parameters

v0: type, The first vector to be compared for equality

v1: type, The second vector to be compared for equality

Returns

Boolean, Whether the vectors are equal within tolerance

equalityNumber(n0, n1)

See if two Numbers are equal within tolerance

Parameters

n0: Number, The first number to be compared for equality

n1: Number, The second number to be compared for equality

Returns

Boolean, Whether the numbers are equal within tolerance

degToRad(degrees)

Convert degrees to radians

Parameters

degrees: Number, Degrees to convert

Returns

Number, Radians conversion

radToDeg(radians)

Convert radians to degress

Parameters

radians: Number, Radians to convert

Returns

Number, Degrees conversion

intersectRayTri(ray, tri)

Collide a Ray with a Triangle

Parameters

ray: Ray, The ray to cast for collision

tri: Triangle, The triangle to check for collision

Returns

Number, Where along the ray the intersection occured

intersectRaySphere(ray, sphere)

Collide a Ray with a Sphere

Parameters

ray: Ray, The ray to cast for collision

sphere: Sphere, the Sphere to check for collision

Returns

Number, Where along the ray the intersection occured

intersect(a, b)

Try and intersect two objects

Parameters

a: Object, The collider object of the collision check

b: Object, The collidee object of the collision check

Returns

Number, The penetration depth of the collision if there was one