Point

A 2D point, { x, y }, or a vector, an offset or a velocity, and its geometry: distance, angle and lerp. A plain object, so any { x, y } is one.

import * as Point from "@wardic/core/Point"

Point.distance({ x: 0, y: 0 }, { x: 3, y: 4 }) // 5

Interfaces

Point

A 2D point, or a 2D vector (a drag offset, a velocity).

Extended by

Properties

x
readonly x: number;

Across.

y
readonly y: number;

Down.

Functions

angle()

function angle(a, b): number;

The angle, in radians, of the line from a to b: 0 along x, π/2 along y.

Parameters

a

Point

b

Point

Returns

number


distance()

function distance(a, b): number;

The distance between two points.

Parameters

a

Point

b

Point

Returns

number


lerp()

function lerp(
   a, 
   b, 
   t
): Point;

The point t of the way from a to b: a at 0, b at 1.

Parameters

a

Point

b

Point

t

number

Returns

Point