genvidMath¶
Functions¶
-
clamp
(v, min, max)¶ Clamps value @x to fall between @min and @max.
Arguments: - v (number) –
- min (number) –
- max (number) –
Returns: number
-
dot2D
(v1, v2)¶ Returns the inner product (i.e. dot product) of two 2D vectors.
Arguments: Returns: number
-
dot3D
(v1, v2)¶ Returns the inner product (i.e. dot product) of two 3D vectors.
Arguments: Returns: number
-
dot4D
(v1, v2)¶ Returns the inner product (i.e. dot product) of two 4D vectors.
Arguments: Returns: number
-
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
-
equal2D
(v0, v1, threshold)¶ Returns true if all components of v0 are within threshold of v1.
Arguments: Returns: boolean
-
equal3D
(v0, v1, threshold)¶ Returns true if all components of v0 are within threshold of v1.
Arguments: Returns: boolean
-
equal4D
(v0, v1, threshold)¶ Returns true if all components of v0 are within threshold of v1.
Arguments: Returns: boolean
-
evalLine2D
(origin, direction, t)¶ Evaluates a parametric line: origin + direction*t.
Arguments: Returns:
-
getDistanceToSegment2D
(pt, segA, segB)¶ Returns the squared distance of point @pt to segment @segA-@segB.
Arguments: Returns: number
-
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
-
getProjectionFactor2D
(vector, axis)¶ Returns the parametric coordinate t of the projection point of vector unto axis.
Arguments: Returns: number
-
getSquaredDistanceToSegment2D
(point, segA, segB)¶ Returns the squared distance of point @pt to segment @segA-@segB.
Arguments: Returns: number
-
homogenize4D
(v)¶ Makes a vec4 homogenous, i.e. that the last component is 1.
Arguments: - v (IVec4) –
Returns:
-
mad2D
(v1, v2, v3)¶ Multiplies @v1 and @v2, then adds @v3 to the result.
Arguments: Returns:
-
mad3D
(v1, v2, v3)¶ Multiplies @v1 and @v2, then adds @v3 to the result.
Arguments: Returns:
-
mat4
(row0, row1, row2, row3)¶ Returns a 4x4 matrix composed of 4 rows.
Arguments: Returns:
-
mix
(v1, v2, t)¶ Linear interpolation between @v1 and @v2 using @t as a parameter.
Arguments: - v1 (any) –
- v2 (any) –
- t (any) –
Returns: any
-
mul2D
(v1, v2)¶ Multiplies 2D vectors @v1 and @v2 together.
Arguments: Returns:
-
mul3D
(v1, v2)¶ Multiplies 2D vectors @v1 and @v2 together.
Arguments: Returns:
-
muls2D
(v1, s)¶ Multiplies a 2D vector @v1 by scalar @s.
Arguments: - v1 (IVec2) –
- s (number) –
Returns:
-
muls3D
(v1, s)¶ Multiplies a 2D vector @v1 by scalar @s.
Arguments: - v1 (IVec3) –
- s (number) –
Returns:
-
muls4D
(v1, s)¶ Multiplies a 4D vector @v1 by scalar @s.
Arguments: - v1 (IVec4) –
- s (number) –
Returns:
-
projectPointUntoSegment2D
(point, segA, segB)¶ Deprecated.
Arguments: Returns:
-
projectPosition
(m, v)¶ Projects a 3D vector @v using the 4x4 matrix @m.
Arguments: Returns:
-
projectUnto2D
(vector, axis)¶ Returns the projection point of vector unto axis.
Arguments: Returns:
-
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