Members
(constant) TAU
The TAU property represents the ratio of the circumference of a circle to its radius. Approximately 6.28318530717958647692
- Source:
Example
const { TAU } = this.maths.constants
Methods
distanceBetween(a, b) → {Number}
Calculates the Euclidean distance between two n-dimensional points.
Parameters:
Name | Type | Description |
---|---|---|
a |
Array | first operand. |
b |
Array | second operand. |
- Source:
Returns:
- distance.
- Type
- Number
Example
const distance = distanceBetween([0, 0], [0, 10]); // calculate distance between 2D points
console.log(distance); // output 10
lengths(segments, bezier)
Divides the bezier curve into line segments and returns the cumulative length of those segments as an array. Utility function used to calculate the curve's approximate length and determine the equivalence between arc length and time.
Parameters:
Name | Type | Description |
---|---|---|
segments |
Number | the number of segments to use when approximating the curve length. |
bezier |
Object | a bezier curve. |
- Source:
Returns:
an array containing the cumulative length of the segments.
Example
const b = bezier.create([[0, 0], [0, 10]]);
const totalLength = lengths(100, b).pop(); // the last element of the array is the curve's approximate length
Type Definitions
VectorCharObject
Represents a character as a list of segments
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
width |
Float | character width |
height |
Float | character height (uppercase) |
segments |
Array | character segments [[[x, y], ...], ...] |
- Source:
bezier
Represents a bezier easing function.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
points |
Array | The control points for the bezier curve. The first and last point will also be the start and end of the curve |
pointType |
string | A reference to the type and dimensionality of the points that the curve was created from |
dimensions |
number | The dimensionality of the bezier |
permutations |
Array | A pre-calculation of the bezier algorithm's co-efficients |
tangentPermutations |
Array | A pre-calculation of the bezier algorithm's tangent co-efficients |
- Source:
geom2
Represents a 2D geometry consisting of a list of sides.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
sides |
Array | list of sides, each side containing two points |
transforms |
mat4 | transforms to apply to the sides, see transform() |
- Source:
geom3
Represents a 3D geometry consisting of a list of polygons.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
polygons |
Array | list of polygons, each polygon containing three or more points |
transforms |
mat4 | transforms to apply to the polygons, see transform() |
- Source:
line2
Represents a unbounded line in 2D space, positioned at a point of origin. A line is parametrized by a normal vector (perpendicular to the line, rotated 90 degrees counter clockwise) and distance from the origin.
Equation: A Point (P) is on Line (L) if dot(L.normal, P) == L.distance
The contents of the array are a normal [0,1] and a distance [2].
Type:
- Array
- Source:
line3
Represents a unbounded line in 3D space, positioned at a point of origin. A line is parametrized by a point of origin and a directional vector.
The array contents are two 3D vectors; origin [0,0,0] and directional vector [0,0,1].
Type:
- Array
mat4
Represents a 4x4 matrix which is column-major (when typed out it looks row-major). See fromValues().
Type:
- Array
- Source:
path2
Represents a 2D geometry consisting of a list of ordered points.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
points |
Array | list of ordered points |
isClosed |
Boolean | true if the path is closed where start and end points are the same |
transforms |
mat4 | transforms to apply to the points, see transform() |
- Source:
plane
Represents a plane in 3D coordinate space as determined by a normal (perpendicular to the plane) and distance from 0,0,0.
The contents of the array are a normal [0,1,2] and a distance [3].
Type:
- Array
- Source:
- See:
poly2
Represents a convex 2D polygon consisting of a list of ordered vertices.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
vertices |
Array | list of ordered vertices (2D) |
- Source:
poly3
Represents a convex 3D polygon. The vertices used to initialize a polygon must
be coplanar and form a convex shape. The vertices do not have to be vec3
instances but they must behave similarly.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
vertices |
Array | list of ordered vertices (3D) |
- Source:
slice
Represents a 3D geometry consisting of a list of edges.
Type:
- Object
Properties:
Name | Type | Description |
---|---|---|
edges |
Array | list of edges, each edge containing two points (3D) |
vec2
Represents a two dimensional vector. See fromValues().
Type:
- Array
- Source:
vec3
Represents a three dimensional vector. See fromValues().
Type:
- Array
- Source:
vec4
Represents a four dimensional vector. See fromValues().
Type:
- Array
- Source: