Helix/Geometry
Basic 2D geometry helpers for points, bearings and distances.
Basic 2D geometry helpers working with {x, y} points.
Import #
import * as Geometry from 'Helix/Geometry';Functions #
bearing
Returns the bearing between two points in degrees, range [0, 360).
bearing(a: { x: number, y: number }, b: { x: number, y: number }): numberbearingTo
Alias with reversed semantics, returns degrees.
bearingTo(a: { x: number, y: number }, b: { x: number, y: number }): numberdistance
Euclidean distance between two points.
distance(a: { x: number, y: number }, b: { x: number, y: number }): numberExamples #
Compute the Euclidean distance and bearing between two points. These helpers are useful for pointer-relative calculations, drag gestures, or any spatial logic operating on {x, y} coordinates.
import * as Geometry from 'Helix/Geometry';
const a = { x: 0, y: 0 };
const b = { x: 10, y: 0 };
Geometry.distance(a, b); // 10
Geometry.bearing(a, b); // 0
Geometry.bearingTo(a, b); // 0