genvidMath

Interfaces

Functions

genvidMath.add2D(v1, v2)

Adds @v1 to @v2.

Arguments:
Returns:

genvidMath.IVec2()

genvidMath.add3D(v1, v2)

Adds @v1 to @v2.

Arguments:
Returns:

genvidMath.IVec3()

genvidMath.clamp(v, min, max)

Clamps value @x to fall between @min and @max.

Arguments:
  • v (number) –
  • min (number) –
  • max (number) –
Returns:

number

genvidMath.dot2D(v1, v2)

Returns the inner product (i.e. dot product) of two 2D vectors.

Arguments:
Returns:

number

genvidMath.dot3D(v1, v2)

Returns the inner product (i.e. dot product) of two 3D vectors.

Arguments:
Returns:

number

genvidMath.dot4D(v1, v2)

Returns the inner product (i.e. dot product) of two 4D vectors.

Arguments:
Returns:

number

genvidMath.equal(v0, v1, threshold)

Return true if v0 and v1 are within threshold of one another.

Arguments:
  • v0 (number) –
  • v1 (number) –
  • threshold (number) –
Returns:

boolean

genvidMath.equal2D(v0, v1, threshold)

Returns true if all components of v0 are within threshold of v1.

Arguments:
Returns:

boolean

genvidMath.equal3D(v0, v1, threshold)

Returns true if all components of v0 are within threshold of v1.

Arguments:
Returns:

boolean

genvidMath.equal4D(v0, v1, threshold)

Returns true if all components of v0 are within threshold of v1.

Arguments:
Returns:

boolean

genvidMath.evalLine2D(origin, direction, t)

Evaluates a parametric line: origin + direction*t.

Arguments:
Returns:

genvidMath.IVec2()

genvidMath.getDistanceToSegment2D(pt, segA, segB)

Returns the squared distance of point @pt to segment @segA-@segB.

Arguments:
Returns:

number

genvidMath.getParameter_ClosestPointToSegment2D(point, segOrigin, segDirection)

Returns the parametric factor (between 0 and 1) corresponding to the point on the segment that is closest to @point. To retrieve the actual point on the segment, call: evalLine2D(segOrigin, segDirection, t);

Arguments:
Returns:

number

genvidMath.getProjectionFactor2D(vector, axis)

Returns the parametric coordinate t of the projection point of vector unto axis.

Arguments:
Returns:

number

genvidMath.getSquaredDistanceToSegment2D(point, segA, segB)

Returns the squared distance of point @pt to segment @segA-@segB.

Arguments:
Returns:

number

genvidMath.homogenize3D(v)

Makes a vec3 homogenous, i.e. that the last component is 1.

Arguments:
Returns:

genvidMath.IVec3()

genvidMath.homogenize4D(v)

Makes a vec4 homogenous, i.e. that the last component is 1.

Arguments:
Returns:

genvidMath.IVec4()

genvidMath.length2D(v)

Returns the norm of a 2D vector.

Arguments:
Returns:

number

genvidMath.length3D(v)

Returns the norm of a 2D vector.

Arguments:
Returns:

number

genvidMath.lengthSq2D(v)

Returns the squared norm of a 2D vector.

Arguments:
Returns:

number

genvidMath.lengthSq3D(v)

Returns the squared norm of a 3D vector.

Arguments:
Returns:

number

genvidMath.mad2D(v1, v2, v3)

Multiplies @v1 and @v2, then adds @v3 to the result.

Arguments:
Returns:

genvidMath.IVec2()

genvidMath.mad3D(v1, v2, v3)

Multiplies @v1 and @v2, then adds @v3 to the result.

Arguments:
Returns:

genvidMath.IVec3()

genvidMath.mat3(row0, row1, row2)

Returns a 3x3 matrix composed of 3 rows.

Arguments:
Returns:

genvidMath.IMat3()

genvidMath.mat3FromArray(rawNumbers)

Builds up a mat3 by feeding it with an array of 9 numbers (column logic)

Arguments:
  • rawNumbers (number) –
Returns:

genvidMath.IMat3()

genvidMath.mat3Identity()

mat3 identity

Returns:genvidMath.IMat3()
genvidMath.mat3ToArray(mat)

Builds up a mat3 by feeding it with an array of 9 numbers

Arguments:
Returns:

number

genvidMath.mat4(row0, row1, row2, row3)

Returns a 4x4 matrix composed of 4 rows.

Arguments:
Returns:

genvidMath.IMat4()

genvidMath.mix(v1, v2, t)

Linear interpolation between @v1 and @v2 using @t as a parameter.

Arguments:
  • v1 (any) –
  • v2 (any) –
  • t (any) –
Returns:

any

genvidMath.mul2D(v1, v2)

Multiplies 2D vectors @v1 and @v2 together.

Arguments:
Returns:

genvidMath.IVec2()

genvidMath.mul3D(v1, v2)

Multiplies 2D vectors @v1 and @v2 together.

Arguments:
Returns:

genvidMath.IVec3()

genvidMath.mulmat3(m, v)

Transforms a vec3 by a mat3.

Arguments:
Returns:

genvidMath.IVec3()

genvidMath.mulmat4(m, v)

Transforms a vec4 by a mat4.

Arguments:
Returns:

genvidMath.IVec4()

genvidMath.muls2D(v1, s)

Multiplies a 2D vector @v1 by scalar @s.

Arguments:
Returns:

genvidMath.IVec2()

genvidMath.muls3D(v1, s)

Multiplies a 2D vector @v1 by scalar @s.

Arguments:
Returns:

genvidMath.IVec3()

genvidMath.muls4D(v1, s)

Multiplies a 4D vector @v1 by scalar @s.

Arguments:
Returns:

genvidMath.IVec4()

genvidMath.normalize2D(v)

Normalizes a vec2 so that its length is 1.

Arguments:
Returns:

genvidMath.IVec2()

genvidMath.normalize3D(v)

Normalizes a vec3 so that its length is 1.

Arguments:
Returns:

genvidMath.IVec3()

genvidMath.prodmat3(m1, m2)

returns the product of 2 mat3

Arguments:
Returns:

genvidMath.IMat3()

genvidMath.projectPointUntoSegment2D(point, segA, segB)

Deprecated.

Arguments:
Returns:

genvidMath.IVec2()

genvidMath.projectPosition(m, v)

Projects a 3D vector @v using the 4x4 matrix @m.

Arguments:
Returns:

genvidMath.IVec3()

genvidMath.projectPosition2(m, v)

Projects a 2D vector @v using the 3x3 matrix @m.

Arguments:
Returns:

genvidMath.IVec2()

genvidMath.projectUnto2D(vector, axis)

Returns the projection point of vector unto axis.

Arguments:
Returns:

genvidMath.IVec2()

genvidMath.sub2D(v1, v2)

Subtracts @v2 from @v1.

Arguments:
Returns:

genvidMath.IVec2()

genvidMath.sub3D(v1, v2)

Subtracts @v2 from @v1.

Arguments:
Returns:

genvidMath.IVec3()

genvidMath.toHTMLColorString(v)

Converts a vec3 into an “rgb(x*255,y*255,z*255)” string, or vec4 into an “rgba(x*255,y*255,z*255,w*255)”. Also accepts structure with {r,g,b,a} elements.

Arguments:
  • v (any) –
Returns:

string

genvidMath.transposemat3(mat)

transpose a mat3

Arguments:
Returns:

genvidMath.IMat3()

genvidMath.transposemat4(mat)

Returns a 4x4 matrix transposed.

Arguments:
Returns:

genvidMath.IMat4()

genvidMath.vec2(x, y)

Returns a 2D vector.

Arguments:
  • x (number) –
  • y (number) –
Returns:

genvidMath.IVec2()

genvidMath.vec3(x, y, z)

Returns a 3D vector.

Arguments:
  • x (number) –
  • y (number) –
  • z (number) –
Returns:

genvidMath.IVec3()

genvidMath.vec4(x, y, z, w)

Returns a 4D vector.

Arguments:
  • x (number) –
  • y (number) –
  • z (number) –
  • w (number) –
Returns:

genvidMath.IVec4()