Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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: 3 months ago
JSON representation

Compute Frenet-Serret frames for a path of 3D points and tangents.

Awesome Lists containing this project

README

        

# frenet-serret-frames

[![npm version](https://img.shields.io/npm/v/frenet-serret-frames)](https://www.npmjs.com/package/frenet-serret-frames)
[![stability-stable](https://img.shields.io/badge/stability-stable-green.svg)](https://www.npmjs.com/package/frenet-serret-frames)
[![npm minzipped size](https://img.shields.io/bundlephobia/minzip/frenet-serret-frames)](https://bundlephobia.com/package/frenet-serret-frames)
[![dependencies](https://img.shields.io/librariesio/release/npm/frenet-serret-frames)](https://github.com/dmnsgn/frenet-serret-frames/blob/main/package.json)
[![types](https://img.shields.io/npm/types/frenet-serret-frames)](https://github.com/microsoft/TypeScript)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-fa6673.svg)](https://conventionalcommits.org)
[![styled with prettier](https://img.shields.io/badge/styled_with-Prettier-f8bc45.svg?logo=prettier)](https://github.com/prettier/prettier)
[![linted with eslint](https://img.shields.io/badge/linted_with-ES_Lint-4B32C3.svg?logo=eslint)](https://github.com/eslint/eslint)
[![license](https://img.shields.io/github/license/dmnsgn/frenet-serret-frames)](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.

[![paypal](https://img.shields.io/badge/donate-paypal-informational?logo=paypal)](https://paypal.me/dmnsgn)
[![coinbase](https://img.shields.io/badge/donate-coinbase-informational?logo=coinbase)](https://commerce.coinbase.com/checkout/56cbdf28-e323-48d8-9c98-7019e72c97f3)
[![twitter](https://img.shields.io/twitter/follow/dmnsgn?style=social)](https://twitter.com/dmnsgn)

![](https://raw.githubusercontent.com/dmnsgn/frenet-serret-frames/main/screenshot.gif)

## 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>

**Kind**: global typedef

## vec3 : Array.<number>

**Kind**: global typedef

## 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).