Members
(constant) TAU
- Source:
The TAU property represents the ratio of the circumference of a circle to its radius. Approximately 6.28318530717958647692
Example
const { TAU } = require('@jscad/modeling').maths.constants
Methods
distanceBetween(a, b) → {Number}
Calculates the Euclidean distance between two n-dimensional points.
Example
const distance = distanceBetween([0, 0], [0, 10]); // calculate distance between 2D points
console.log(distance); // output 10
Parameters:
Name | Type | Description |
---|---|---|
a |
Array | first operand. |
b |
Array | second operand. |
Returns:
- distance.
- Type
- Number
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.
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
Parameters:
Name | Type | Description |
---|---|---|
segments |
Number | the number of segments to use when approximating the curve length. |
bezier |
Object | a bezier curve. |
Returns:
an array containing the cumulative length of the segments.
Type Definitions
bezier
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 |
Represents a bezier easing function.
Type:
- Object
geom2
Properties:
Name | Type | Description |
---|---|---|
sides |
Array | list of sides, each side containing two points |
transforms |
mat4 | transforms to apply to the sides, see transform() |
Represents a 2D geometry consisting of a list of sides.
Type:
- Object
geom3
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() |
Represents a 3D geometry consisting of a list of polygons.
Type:
- Object
line2
- Source:
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
line3
- Source:
- See:
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
- Source:
Represents a 4x4 matrix which is column-major (when typed out it looks row-major). See fromValues().
Type:
- Array
path2
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() |
Represents a 2D geometry consisting of a list of ordered points.
Type:
- Object
plane
- Source:
- See:
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
poly2
Properties:
Name | Type | Description |
---|---|---|
vertices |
Array | list of ordered vertices (2D) |
Represents a convex 2D polygon consisting of a list of ordered vertices.
Type:
- Object
poly3
Properties:
Name | Type | Description |
---|---|---|
vertices |
Array | list of ordered vertices (3D) |
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
slice
Properties:
Name | Type | Description |
---|---|---|
edges |
Array | list of edges, each edge containing two points (3D) |
Represents a 3D geometry consisting of a list of edges.
Type:
- Object
vec2
- Source:
Represents a two dimensional vector. See fromValues().
Type:
- Array
vec3
- Source:
Represents a three dimensional vector. See fromValues().
Type:
- Array
vec4
- Source:
Represents a four dimensional vector. See fromValues().
Type:
- Array
VectorCharObject
- Source:
Properties:
Name | Type | Description |
---|---|---|
width |
Float | character width |
height |
Float | character height (uppercase) |
segments |
Array | character segments [[[x, y], ...], ...] |
Represents a character as a list of segments
Type:
- Object