https://github.com/dmnsgn/frenet-serret-frames
Compute Frenet-Serret frames for a path of 3D points and tangents.
https://github.com/dmnsgn/frenet-serret-frames
algorithm frenet-serret-frame geometry tangent
Last synced: 19 days ago
JSON representation
Compute Frenet-Serret frames for a path of 3D points and tangents.
- Host: GitHub
- URL: https://github.com/dmnsgn/frenet-serret-frames
- Owner: dmnsgn
- License: mit
- Created: 2018-09-12T15:06:40.000Z (over 6 years ago)
- Default Branch: main
- Last Pushed: 2024-07-07T14:54:01.000Z (11 months ago)
- Last Synced: 2025-04-20T22:32:51.697Z (29 days ago)
- Topics: algorithm, frenet-serret-frame, geometry, tangent
- Language: JavaScript
- Homepage: https://dmnsgn.github.io/frenet-serret-frames/
- Size: 2.1 MB
- Stars: 26
- Watchers: 2
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# frenet-serret-frames
[](https://www.npmjs.com/package/frenet-serret-frames)
[](https://www.npmjs.com/package/frenet-serret-frames)
[](https://bundlephobia.com/package/frenet-serret-frames)
[](https://github.com/dmnsgn/frenet-serret-frames/blob/main/package.json)
[](https://github.com/microsoft/TypeScript)
[](https://conventionalcommits.org)
[](https://github.com/prettier/prettier)
[](https://github.com/eslint/eslint)
[](https://github.com/dmnsgn/frenet-serret-frames/blob/main/LICENSE.md)Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.
[](https://paypal.me/dmnsgn)
[](https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3)
[](https://twitter.com/dmnsgn)
## Installation
```bash
npm install frenet-serret-frames
```## Usage
```js
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
](#SimplicialComplexWithTNB)
Compute Frenet-Serret frames for a geometry of 3D positions and optionally provided tangents.
**Kind**: global function
**See**: [Frenet–Serret formulas](https://en.wikipedia.org/wiki/Frenet%E2%80%93Serret_formulas)
| Param | Type | Default |
| --------- | ---------------------------------------------------- | --------------- |
| geometry | [SimplicialComplex
](#SimplicialComplex) | |
| [options] | [Options
](#Options) | {}
|
## vec2 : Array.<number>
## vec3 : Array.<number>
## SimplicialComplex : object
Geometry definition.
**Kind**: global typedef
**Properties**
| Name | Type |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| positions | Float32Array
\| Array
\| [Array.<vec3>
](#vec3) |
| [tangents] | Float32Array
\| Array
\| [Array.<vec3>
](#vec3) |
| [normals] | Float32Array
\| Array
\| [Array.<vec3>
](#vec3) |
| [uvs] | Float32Array
\| Array
\| [Array.<vec2>
](#vec2) |
| [cells] | Uint8Array
\| Uint16Array
\| Uint32Array
\| Array
\| [Array.<vec3>
](#vec3) |
## SimplicialComplexWithTNB : object
Geometry definition augmented with tangents, normals and binormals.
**Kind**: global typedef
**Properties**
| Name | Type |
| --------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
| positions | Float32Array
\| Array
\| [Array.<vec3>
](#vec3) |
| tangents | Float32Array
\| Array
\| [Array.<vec3>
](#vec3) |
| normals | Float32Array
\| Array
\| [Array.<vec3>
](#vec3) |
| binormals | Float32Array
\| Array
\| [Array.<vec3>
](#vec3) |
| [uvs] | Float32Array
\| Array
\| [Array.<vec2>
](#vec2) |
| [cells] | Uint8Array
\| Uint16Array
\| Uint32Array
\| Array
\| [Array.<vec3>
](#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
](#vec3) | | Specify a starting normal for the frames. Default to the direction of the minimum tangent component. |
## License
MIT. See [license file](https://github.com/dmnsgn/frenet-serret-frames/blob/main/LICENSE.md).