0.0.11 • Published 3 years ago

polf v0.0.11

Weekly downloads
10
License
GPL-3.0
Repository
github
Last release
3 years ago

📦 polf

NPM version License NodeJS versions

Find point coordinates inside line functions between a range t from 0 to 1.

Status

Tests Coverage status

Installation

npm install polf

Quickstart

> const { lineXY } = require("polf");
> lineXY([0, 0], [10, 10], .5)
[ 5, 5 ]

Documentation

Point on line functions

Utility functions

Point on line functions

# lineXY(p0, p1, t) ⇒ array

Computes the coordinate of a point in a line parametrized in the range t from 0 to 1.

Algorithm: B(t) = p0 + (p1 - p0) * t , 0 <= t <= 1

  • p0 (array) Start point coordinate.
  • p1 (array) End point coordinate.
  • t (number) Number in the range from 0 to 1 that parametrizes the location on the line.

# cubicBezierXY(p0, p1, p2, p3, t) ⇒ array

Computes the coordinate of a point in a cubic Bézier curve parametrized in the range t from 0 to 1.

Algorithm: B(t) = (1-t)^3 * p0 + 3*(1-t)^2 * t * p1 + 3*(1-t)^2 * p2 + t^3 * p3 , 0 <= t <= 1

  • p0 (array) Start point coordinate.
  • p1 (array) First control point coordinate.
  • p2 (array) Second control point coordinate.
  • p3 (array) End point coordinate.
  • t (number) Number in the range from 0 to 1 that parametrizes the location on the curve.

# quadraticBezierXY(p0, p1, p2, t) ⇒ array

Computes the coordinate of a point in a quadratic Bézier curve parametrized in the range t from 0 to 1.

Algorithm: B(t) = (1-t) * 2 * p0 + 2*(1-t)*t * p1 + t2 * p2 , 0 <= t <= 1

  • p0 (array) Start point coordinate.
  • p1 (array) Coordinate of the control point.
  • p2 (array) End point coordinate.
  • t (number) Number in the range from 0 to 1 that parametrizes the location on the curve.

# ellipticalArcXY(p0, rx, ry, xAxisRotation, largeArc, sweep, p1, t) ⇒ array

Computes the coordinate of a point in a elliptical arc parametrized in the range t from 0 to 1.

  • p0 (array) Start point coordinate.
  • rx (number) X radius of the arc.
  • ry (number) Y radius of the arc.
  • xAxisRotation (number) Rotation in X of the arc in degrees.
  • largeArc (boolean) large-arc flag that specifies how the arc is drawn.
  • sweep (boolean) sweep flag that specifies how the arc is drawn.
  • p1 (array) End point coordinate.
  • t (number) Number in the range from 0 to 1 that parametrizes the location on the arc.

Utility functions

# angleBetween(v0, v1) ⇒ number

Computes the angle between two vectors.

  • v0 (array) First vector in comparison.
  • v1 (array) Second vector in comparison.
0.0.11

3 years ago

0.0.10

3 years ago

0.0.9

3 years ago

0.0.8

3 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago