# polf

0.0.11 • Public • Published

# 📦 polf

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

## Installation

``````npm install polf
``````

## Quickstart

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

## Documentation

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

## Package Sidebar

### Install

`npm i polf`

### Repository

github.com/mondeja/polf

126

0.0.11

GPL-3.0

17.9 kB

10