frenet-serret-frames
frenet-serret-frames copied to clipboard
Compute Frenet-Serret frames for a path of 3D points and tangents.
frenet-serret-frames
Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.
Installation
npm install frenet-serret-frames
Usage
import frenetSerretFrames from "frenet-serret-frames";
const geometry = { positions, cells };
frenetSerretFrames(geometry, {
closed: true,
initialNormal: [0, 1, 0],
});
console.log(geometry);
// {
// positions: Float32Array [x, y, z, x, y, z, ...],
// tangents: Float32Array [x, y, z, x, y, z, ...]
// normals: Float32Array [x, y, z, x, y, z, ...]
// binormals: Float32Array [x, y, z, x, y, z, ...]
// cells: Uint8/16/32/Array [a, b, c, a, b, c, ...],
// }
API
Functions
- frenetSerretFrames(geometry, [options]) ⇒
SimplicialComplexWithTNB
Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.
Typedefs
- vec2 :
Array.<number>
- vec3 :
Array.<number>
- SimplicialComplex :
object
Geometry definition.
- SimplicialComplexWithTNB :
object
Geometry definition augmented with tangents, normals and binormals.
- Options :
object
Options for frames computation. All optional.
frenetSerretFrames(geometry, [options]) ⇒ SimplicialComplexWithTNB
Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.
Kind: global function See: Frenet–Serret formulas
Param | Type | Default |
---|---|---|
geometry | SimplicialComplex |
|
[options] | Options |
{} |
vec2 : Array.<number>
Kind: global typedef
vec3 : Array.<number>
Kind: global typedef
SimplicialComplex : object
Geometry definition.
Kind: global typedef Properties
Name | Type |
---|---|
positions | Float32Array | Array | Array.<vec3> |
[tangents] | Float32Array | Array | Array.<vec3> |
[normals] | Float32Array | Array | Array.<vec3> |
[uvs] | Float32Array | Array | Array.<vec2> |
[cells] | Uint8Array | Uint16Array | Uint32Array | Array | Array.<vec3> |
SimplicialComplexWithTNB : object
Geometry definition augmented with tangents, normals and binormals.
Kind: global typedef Properties
Name | Type |
---|---|
positions | Float32Array | Array | Array.<vec3> |
tangents | Float32Array | Array | Array.<vec3> |
normals | Float32Array | Array | Array.<vec3> |
binormals | Float32Array | Array | Array.<vec3> |
[uvs] | Float32Array | Array | Array.<vec2> |
[cells] | Uint8Array | Uint16Array | Uint32Array | Array | Array.<vec3> |
Options : object
Options for frames computation. All optional.
Kind: global typedef Properties
Name | Type | Default | Description |
---|---|---|---|
[closed] | boolean |
false |
Specify is the path is closed. |
[initialNormal] | vec3 |
|
Specify a starting normal for the frames. Default to the direction of the minimum tangent component. |
License
MIT. See license file.