Table of contents

Public class

Signature
class Vec {}
Source

packages/editor/src/lib/primitives/Vec.ts


Constructor

Public constructor

Constructs a new instance of the Vec class

Parameters
NameDescription

x

number

y

number

z

number

Properties

pressure

Public readonly property

Signature
get pressure(): number

x

Public property

Signature
x: number

y

Public property

Signature
y: number

z

Public property

Signature
z: number

Methods

abs()

Public method

Signature
abs(): this

Abs()

Public static method

Signature
static Abs(A: VecLike): Vec
Parameters
NameDescription

A

VecLike
Returns
Vec
References

VecLike, Vec


add()

Public method

Signature
add(V: VecLike): this
Parameters
NameDescription

V

VecLike
Returns
this
References

VecLike


Add()

Public static method

Signature
static Add(A: VecLike, B: VecLike): Vec
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
Vec
References

VecLike, Vec


addScalar()

Public method

Signature
addScalar(n: number): this
Parameters
NameDescription

n

number
Returns
this

AddScalar()

Public static method

Signature
static AddScalar(A: VecLike, n: number): Vec
Parameters
NameDescription

A

VecLike

n

number
Returns
Vec
References

VecLike, Vec


addXY()

Public method

Signature
addXY(x: number, y: number): this
Parameters
NameDescription

x

number

y

number
Returns
this

AddXY()

Public static method

Signature
static AddXY(A: VecLike, x: number, y: number): Vec
Parameters
NameDescription

A

VecLike

x

number

y

number
Returns
Vec
References

VecLike, Vec


angle()

Public method

Signature
angle(B: VecLike): number
Parameters
NameDescription

B

VecLike
Returns
number
References

VecLike


Angle()

Public static method

Signature
static Angle(A: VecLike, B: VecLike): number
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
number
References

VecLike


Average()

Public static method

Signature
static Average(arr: VecLike[]): Vec
Parameters
NameDescription

arr

VecLike[]
Returns
Vec
References

VecLike, Vec


Cast()

Public static method

Signature
static Cast(A: VecLike): Vec
Parameters
NameDescription

A

VecLike
Returns
Vec
References

VecLike, Vec


clamp()

Public method

Signature
clamp(min: number, max?: number): this
Parameters
NameDescription

min

number

max

number
Returns
this

Clamp()

Public static method

Signature
static Clamp(A: Vec, min: number, max?: number): Vec
Parameters
NameDescription

A

Vec

min

number

max

number
Returns
Vec
References

Vec


Clockwise()

Public static method

Signature
static Clockwise(A: VecLike, B: VecLike, C: VecLike): boolean
Parameters
NameDescription

A

VecLike

B

VecLike

C

VecLike
Returns
boolean
References

VecLike


clone()

Public method

Signature
clone(): Vec
References

Vec


cpr()

Public method

Signature
cpr(V: VecLike): number
Parameters
NameDescription

V

VecLike
Returns
number
References

VecLike


Cpr()

Public static method

Cross product of two vectors which is used to calculate the area of a parallelogram.

Signature
static Cpr(A: VecLike, B: VecLike): number
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
number
References

VecLike


cross()

Public method

Signature
cross(V: VecLike): this
Parameters
NameDescription

V

VecLike
Returns
this
References

VecLike


Cross()

Public static method

Signature
static Cross(A: VecLike, V: VecLike): Vec
Parameters
NameDescription

A

VecLike

V

VecLike
Returns
Vec
References

VecLike, Vec


dist()

Public method

Signature
dist(V: VecLike): number
Parameters
NameDescription

V

VecLike
Returns
number
References

VecLike


Dist()

Public static method

Signature
static Dist(A: VecLike, B: VecLike): number
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
number
References

VecLike


Dist2()

Public static method

Signature
static Dist2(A: VecLike, B: VecLike): number
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
number
References

VecLike


distanceToLineSegment()

Public method

Signature
distanceToLineSegment(A: VecLike, B: VecLike): number
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
number
References

VecLike


DistanceToLineSegment()

Public static method

Signature
static DistanceToLineSegment(
  A: VecLike,
  B: VecLike,
  P: VecLike,
  clamp?: boolean
): number
Parameters
NameDescription

A

VecLike

B

VecLike

P

VecLike

clamp

boolean
Returns
number
References

VecLike


DistanceToLineThroughPoint()

Public static method

Signature
static DistanceToLineThroughPoint(A: VecLike, u: VecLike, P: VecLike): number
Parameters
NameDescription

A

VecLike

u

VecLike

P

VecLike
Returns
number
References

VecLike


div()

Public method

Signature
div(t: number): this
Parameters
NameDescription

t

number
Returns
this

Div()

Public static method

Signature
static Div(A: VecLike, t: number): Vec
Parameters
NameDescription

A

VecLike

t

number
Returns
Vec
References

VecLike, Vec


divV()

Public method

Signature
divV(V: VecLike): this
Parameters
NameDescription

V

VecLike
Returns
this
References

VecLike


DivV()

Public static method

Signature
static DivV(A: VecLike, B: VecLike): Vec
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
Vec
References

VecLike, Vec


dpr()

Public method

Signature
dpr(V: VecLike): number
Parameters
NameDescription

V

VecLike
Returns
number
References

VecLike


Dpr()

Public static method

Dot product of two vectors which is used to calculate the angle between them.

Signature
static Dpr(A: VecLike, B: VecLike): number
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
number
References

VecLike


equals()

Public method

Signature
equals(B: VecLike): boolean
Parameters
NameDescription

B

VecLike
Returns
boolean
References

VecLike


Equals()

Public static method

Signature
static Equals(A: VecLike, B: VecLike): boolean
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
boolean
References

VecLike


equalsXY()

Public method

Signature
equalsXY(x: number, y: number): boolean
Parameters
NameDescription

x

number

y

number
Returns
boolean

EqualsXY()

Public static method

Signature
static EqualsXY(A: VecLike, x: number, y: number): boolean
Parameters
NameDescription

A

VecLike

x

number

y

number
Returns
boolean
References

VecLike


From()

Public static method

Signature
static From({ x, y, z }: VecModel): Vec
Parameters
NameDescription

{ x, y, z }

VecModel
Returns
Vec
References

VecModel, Vec


FromAngle()

Public static method

Signature
static FromAngle(r: number, length?: number): Vec
Parameters
NameDescription

r

number

length

number
Returns
Vec
References

Vec


FromArray()

Public static method

Signature
static FromArray(v: number[]): Vec
Parameters
NameDescription

v

number[]
Returns
Vec
References

Vec


len()

Public method

Signature
len(): number

Len()

Public static method

Signature
static Len(A: VecLike): number
Parameters
NameDescription

A

VecLike
Returns
number
References

VecLike


len2()

Public method

Signature
len2(): number

Len2()

Public static method

Signature
static Len2(A: VecLike): number
Parameters
NameDescription

A

VecLike
Returns
number
References

VecLike


lrp()

Public method

Signature
lrp(B: VecLike, t: number): Vec
Parameters
NameDescription

B

VecLike

t

number
Returns
Vec
References

VecLike, Vec


Lrp()

Public static method

Linearly interpolate between two points.

Signature
static Lrp(A: VecLike, B: VecLike, t: number): Vec
Parameters
NameDescription

A

VecLike

The first point.

B

VecLike

The second point.

t

number

The interpolation value between 0 and 1.

Returns
Vec

The interpolated point.

References

VecLike, Vec


Max()

Public static method

Signature
static Max(A: VecLike, B: VecLike): Vec
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
Vec
References

VecLike, Vec


Med()

Public static method

Signature
static Med(A: VecLike, B: VecLike): Vec
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
Vec
References

VecLike, Vec


Min()

Public static method

Signature
static Min(A: VecLike, B: VecLike): Vec
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
Vec
References

VecLike, Vec


mul()

Public method

Signature
mul(t: number): this
Parameters
NameDescription

t

number
Returns
this

Mul()

Public static method

Signature
static Mul(A: VecLike, t: number): Vec
Parameters
NameDescription

A

VecLike

t

number
Returns
Vec
References

VecLike, Vec


mulV()

Public method

Signature
mulV(V: VecLike): this
Parameters
NameDescription

V

VecLike
Returns
this
References

VecLike


MulV()

Public static method

Signature
static MulV(A: VecLike, B: VecLike): Vec
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
Vec
References

VecLike, Vec


NearestPointOnLineSegment()

Public static method

Signature
static NearestPointOnLineSegment(
  A: VecLike,
  B: VecLike,
  P: VecLike,
  clamp?: boolean
): Vec
Parameters
NameDescription

A

VecLike

B

VecLike

P

VecLike

clamp

boolean
Returns
Vec
References

VecLike, Vec


NearestPointOnLineThroughPoint()

Public static method

Get the nearest point on a line with a known unit vector that passes through point A

Vec.nearestPointOnLineThroughPoint(A, u, Point)
Signature
static NearestPointOnLineThroughPoint(A: VecLike, u: VecLike, P: VecLike): Vec
Parameters
NameDescription

A

VecLike

Any point on the line

u

VecLike

The unit vector for the line.

P

VecLike

A point not on the line to test.

Returns
Vec
References

VecLike, Vec


neg()

Public method

Signature
neg(): this

Neg()

Public static method

Signature
static Neg(A: VecLike): Vec
Parameters
NameDescription

A

VecLike
Returns
Vec
References

VecLike, Vec


norm()

Public method

Signature
norm(): this

nudge()

Public method

Signature
nudge(B: VecLike, distance: number): this
Parameters
NameDescription

B

VecLike

distance

number
Returns
this
References

VecLike


Nudge()

Public static method

Signature
static Nudge(A: VecLike, B: VecLike, distance: number): Vec
Parameters
NameDescription

A

VecLike

B

VecLike

distance

number
Returns
Vec
References

VecLike, Vec


per()

Public method

Signature
per(): this

Per()

Public static method

Get the perpendicular vector to A.

Signature
static Per(A: VecLike): Vec
Parameters
NameDescription

A

VecLike
Returns
Vec
References

VecLike, Vec


PointsBetween()

Public static method

Get an array of points (with simulated pressure) between two points.

Signature
static PointsBetween(A: VecModel, B: VecModel, steps?: number): Vec[]
Parameters
NameDescription

A

VecModel

The first point.

B

VecModel

The second point.

steps

number

The number of points to return.

Returns
Vec[]
References

VecModel, Vec


pry()

Public method

Signature
pry(V: VecLike): number
Parameters
NameDescription

V

VecLike
Returns
number
References

VecLike


Pry()

Public static method

Get the projection of A onto B.

Signature
static Pry(A: VecLike, B: VecLike): number
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
number
References

VecLike


Rescale()

Public static method

Signature
static Rescale(A: VecLike, n: number): Vec
Parameters
NameDescription

A

VecLike

n

number
Returns
Vec
References

VecLike, Vec


rot()

Public method

Signature
rot(r: number): this
Parameters
NameDescription

r

number
Returns
this

Rot()

Public static method

Signature
static Rot(A: VecLike, r?: number): Vec
Parameters
NameDescription

A

VecLike

r

number
Returns
Vec
References

VecLike, Vec


rotWith()

Public method

Signature
rotWith(C: VecLike, r: number): this
Parameters
NameDescription

C

VecLike

r

number
Returns
this
References

VecLike


RotWith()

Public static method

Signature
static RotWith(A: VecLike, C: VecLike, r: number): Vec
Parameters
NameDescription

A

VecLike

C

VecLike

r

number
Returns
Vec
References

VecLike, Vec


ScaleWithOrigin()

Public static method

Signature
static ScaleWithOrigin(A: VecLike, scale: number, origin: VecLike): Vec
Parameters
NameDescription

A

VecLike

scale

number

origin

VecLike
Returns
Vec
References

VecLike, Vec


set()

Public method

Signature
set(x?: number, y?: number, z?: number): this
Parameters
NameDescription

x

number

y

number

z

number
Returns
this

setTo()

Public method

Signature
setTo({ x, y, z }: VecLike): this
Parameters
NameDescription

{ x, y, z }

VecLike
Returns
this
References

VecLike


slope()

Public method

Signature
slope(B: VecLike): number
Parameters
NameDescription

B

VecLike
Returns
number
References

VecLike


Slope()

Public static method

Signature
static Slope(A: VecLike, B: VecLike): number
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
number
References

VecLike


Snap()

Public static method

Signature
static Snap(A: VecLike, step?: number): Vec
Parameters
NameDescription

A

VecLike

step

number
Returns
Vec
References

VecLike, Vec


snapToGrid()

Public method

Signature
snapToGrid(gridSize: number): this
Parameters
NameDescription

gridSize

number
Returns
this

SnapToGrid()

Public static method

Signature
static SnapToGrid(A: VecLike, gridSize?: number): Vec
Parameters
NameDescription

A

VecLike

gridSize

number
Returns
Vec
References

VecLike, Vec


sub()

Public method

Signature
sub(V: VecLike): this
Parameters
NameDescription

V

VecLike
Returns
this
References

VecLike


Sub()

Public static method

Signature
static Sub(A: VecLike, B: VecLike): Vec
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
Vec
References

VecLike, Vec


subScalar()

Public method

Signature
subScalar(n: number): this
Parameters
NameDescription

n

number
Returns
this

SubScalar()

Public static method

Signature
static SubScalar(A: VecLike, n: number): Vec
Parameters
NameDescription

A

VecLike

n

number
Returns
Vec
References

VecLike, Vec


subXY()

Public method

Signature
subXY(x: number, y: number): this
Parameters
NameDescription

x

number

y

number
Returns
this

SubXY()

Public static method

Signature
static SubXY(A: VecLike, x: number, y: number): Vec
Parameters
NameDescription

A

VecLike

x

number

y

number
Returns
Vec
References

VecLike, Vec


tan()

Public method

Signature
tan(V: VecLike): Vec
Parameters
NameDescription

V

VecLike
Returns
Vec
References

VecLike, Vec


Tan()

Public static method

Signature
static Tan(A: VecLike, B: VecLike): Vec
Parameters
NameDescription

A

VecLike

B

VecLike
Returns
Vec
References

VecLike, Vec


toAngle()

Public method

Signature
toAngle(): number

ToAngle()

Public static method

Signature
static ToAngle(A: VecLike): number
Parameters
NameDescription

A

VecLike
Returns
number
References

VecLike


toArray()

Public method

Signature
toArray(): number[]

ToArray()

Public static method

Signature
static ToArray(A: VecLike): number[]
Parameters
NameDescription

A

VecLike
Returns
number[]
References

VecLike


toFixed()

Public method

Signature
toFixed(): Vec
References

Vec


ToFixed()

Public static method

Signature
static ToFixed(A: VecLike, n?: number): Vec
Parameters
NameDescription

A

VecLike

n

number
Returns
Vec
References

VecLike, Vec


toJson()

Public method

Signature
toJson(): VecModel
References

VecModel


ToJson()

Public static method

Signature
static ToJson(A: VecLike): {
  x: number
  y: number
  z: number | undefined
}
Parameters
NameDescription

A

VecLike
Returns
{
  x: number
  y: number
  z: number | undefined
}
References

VecLike


toString()

Public method

Signature
toString(): string

ToString()

Public static method

Signature
static ToString(A: VecLike): string
Parameters
NameDescription

A

VecLike
Returns
string
References

VecLike


uni()

Public method

Signature
uni(): Vec
References

Vec


Uni()

Public static method

Get the unit vector of A.

Signature
static Uni(A: VecLike): Vec
Parameters
NameDescription

A

VecLike
Returns
Vec
References

VecLike, Vec


useTransformVecLike