Skip to content

point2 overview


Table of contents


utils

Pnt2 (class)

Signature

export declare class Pnt2

clone (static method)

clone point

Signature

static clone(p: Point2): Point2

spr (static method)

spread point components

Signature

static spr(p: Point2): [number, number]

neg (static method)

get negation of the point

Signature

static neg(p: Point2): Point2

add (static method)

add point b to point a

Signature

static add(a: Point2, b: Point2): Point2

sub (static method)

subtract point b from point a

Signature

static sub(a: Point2, b: Point2): Point2

scale (static method)

scale point b by point. The result is the point, where each component is a product of appropriate components of input points

Signature

static scale(a: Point2, s: Point2): Point2

avg (static method)

average point between a and b

Signature

static avg(a: Point2, b: Point2): Point2

round (static method)

round point components

Signature

static round(p: Point2): Point2

lenSq (static method)

calculate vector length (squared)

Signature

static lenSq(v: Point2)

len (static method)

calculate vector length

Signature

static len(v: Point2)

dist (static method)

distance between points

Signature

static dist(a: Point2, b: Point2): number

norm (static method)

normalize

Signature

static norm(p: Point2): Point2

scalarMult (static method)

scalar multiplication

Signature

static scalarMult(p: Point2, m: number): Point2

lerp (static method)

linear interpolation

Signature

static lerp(a: Point2, b: Point2, t: number): Point2

angle (static method)

angle between vectors in radians

Signature

static angle(a: Point2, b: Point2): number

rot (static method)

rotate point around zero by provided angle

Signature

static rot(p: Point2, angle: number): Point2

rotAround (static method)

rotate point around pivot by provided angle

Signature

static rotAround(p: Point2, pivot: Point2, angle: number): Point2