Table of contents
- pressure
- x
- y
- z
- Properties
- Methods
- Abs
- Add
- AddScalar
- AddXY
- Angle
- Average
- Cast
- Clamp
- Clockwise
- Cpr
- Cross
- Dist
- Dist2
- DistanceToLineSegment
- DistanceToLineThroughPoint
- DistMin
- Div
- DivV
- Dpr
- Equals
- EqualsXY
- From
- FromAngle
- FromArray
- IsNaN
- Len
- Len2
- Lrp
- Max
- Med
- Min
- Mul
- MulV
- NearestPointOnLineSegment
- NearestPointOnLineThroughPoint
- Neg
- Nudge
- Per
- PointsBetween
- Pry
- Rescale
- Rot
- RotWith
- ScaleWithOrigin
- Slope
- Snap
- SnapToGrid
- Sub
- SubScalar
- SubXY
- Tan
- ToAngle
- ToArray
- ToCss
- ToFixed
- ToInt
- ToJson
- ToString
- Uni
- abs
- add
- addScalar
- addXY
- angle
- clamp
- clone
- cpr
- cross
- dist
- distanceToLineSegment
- div
- divV
- dpr
- equals
- equalsXY
- len
- len2
- lrp
- mul
- mulV
- neg
- norm
- nudge
- per
- pry
- rot
- rotWith
- set
- setTo
- slope
- snapToGrid
- sub
- subScalar
- subXY
- tan
- toAngle
- toArray
- toFixed
- toJson
- toString
- uni
class Vec {}
Constructor
Constructs a new instance of the Vec
class
Parameters
Name | Description |
---|---|
|
|
|
|
|
|
Properties
pressure
get pressure(): number
x
x: number
y
y: number
z
z: number
Methods
Abs()
Parameters
Name | Description |
---|---|
|
Returns
Add()
Parameters
Returns
AddScalar()
Parameters
Name | Description |
---|---|
| |
|
|
Returns
AddXY()
Parameters
Name | Description |
---|---|
| |
|
|
|
|
Returns
Angle()
Parameters
Returns
number
Average()
Parameters
Name | Description |
---|---|
|
|
Returns
Cast()
Parameters
Name | Description |
---|---|
|
Returns
Clamp()
Parameters
Name | Description |
---|---|
| |
|
|
|
|
Returns
Clockwise()
Parameters
Returns
boolean
Cpr()
Cross product of two vectors which is used to calculate the area of a parallelogram.
Parameters
Returns
number
Cross()
Parameters
Returns
Dist()
Parameters
Returns
number
Dist2()
Parameters
Returns
number
DistanceToLineSegment()
Parameters
Returns
number
DistanceToLineThroughPoint()
Parameters
Returns
number
DistMin()
Parameters
Returns
boolean
Div()
Parameters
Name | Description |
---|---|
| |
|
|
Returns
DivV()
Parameters
Returns
Dpr()
Dot product of two vectors which is used to calculate the angle between them.
Parameters
Returns
number
Equals()
Parameters
Returns
boolean
EqualsXY()
static EqualsXY(A: VecLike, x: number, y: number): boolean
Parameters
Name | Description |
---|---|
| |
|
|
|
|
Returns
boolean
From()
Parameters
Name | Description |
---|---|
|
Returns
FromAngle()
static FromAngle(r: number, length?: number): Vec
Parameters
Name | Description |
---|---|
|
|
|
|
Returns
FromArray()
static FromArray(v: number[]): Vec
Parameters
Name | Description |
---|---|
|
|
Returns
IsNaN()
static IsNaN(A: VecLike): boolean
Parameters
Name | Description |
---|---|
|
Returns
boolean
Len()
static Len(A: VecLike): number
Parameters
Name | Description |
---|---|
|
Returns
number
Len2()
static Len2(A: VecLike): number
Parameters
Name | Description |
---|---|
|
Returns
number
Lrp()
Linearly interpolate between two points.
Parameters
Name | Description |
---|---|
| The first point. |
| The second point. |
|
The interpolation value between 0 and 1. |
Returns
The interpolated point.
Max()
Parameters
Returns
Med()
Parameters
Returns
Min()
Parameters
Returns
Mul()
Parameters
Name | Description |
---|---|
| |
|
|
Returns
MulV()
Parameters
Returns
NearestPointOnLineSegment()
Parameters
Returns
NearestPointOnLineThroughPoint()
Get the nearest point on a line with a known unit vector that passes through point A
Vec.nearestPointOnLineThroughPoint(A, u, Point)
Parameters
Name | Description |
---|---|
| Any point on the line |
| The unit vector for the line. |
| A point not on the line to test. |
Returns
Neg()
Parameters
Name | Description |
---|---|
|
Returns
Nudge()
Parameters
Returns
Per()
Get the perpendicular vector to A.
Parameters
Name | Description |
---|---|
|
Returns
PointsBetween()
Get an array of points (with simulated pressure) between two points.
Parameters
Name | Description |
---|---|
| The first point. |
| The second point. |
|
The number of points to return. |
Returns
Vec[]
Pry()
Get the projection of A onto B.
Parameters
Returns
number
Rescale()
Parameters
Name | Description |
---|---|
| |
|
|
Returns
Rot()
Parameters
Name | Description |
---|---|
| |
|
|
Returns
RotWith()
Parameters
Returns
ScaleWithOrigin()
Parameters
Returns
Slope()
Parameters
Returns
number
Snap()
Parameters
Name | Description |
---|---|
| |
|
|
Returns
SnapToGrid()
Parameters
Name | Description |
---|---|
| |
|
|
Returns
Sub()
Parameters
Returns
SubScalar()
Parameters
Name | Description |
---|---|
| |
|
|
Returns
SubXY()
Parameters
Name | Description |
---|---|
| |
|
|
|
|
Returns
Tan()
Parameters
Returns
ToAngle()
static ToAngle(A: VecLike): number
Parameters
Name | Description |
---|---|
|
Returns
number
ToArray()
static ToArray(A: VecLike): number[]
Parameters
Name | Description |
---|---|
|
Returns
number[]
ToCss()
static ToCss(A: VecLike): string
Parameters
Name | Description |
---|---|
|
Returns
string
ToFixed()
Parameters
Name | Description |
---|---|
|
Returns
ToInt()
Parameters
Name | Description |
---|---|
|
Returns
ToJson()
static ToJson(A: VecLike): {
x: number
y: number
z: number | undefined
}
Parameters
Name | Description |
---|---|
|
Returns
{
x: number
y: number
z: number | undefined
}
ToString()
static ToString(A: VecLike): string
Parameters
Name | Description |
---|---|
|
Returns
string
Uni()
Get the unit vector of A.
Parameters
Name | Description |
---|---|
|
Returns
abs()
abs(): this
add()
add(V: VecLike): this
Parameters
Name | Description |
---|---|
|
Returns
this
addScalar()
addScalar(n: number): this
Parameters
Name | Description |
---|---|
|
|
Returns
this
addXY()
addXY(x: number, y: number): this
Parameters
Name | Description |
---|---|
|
|
|
|
Returns
this
angle()
angle(B: VecLike): number
Parameters
Name | Description |
---|---|
|
Returns
number
clamp()
clamp(min: number, max?: number): this
Parameters
Name | Description |
---|---|
|
|
|
|
Returns
this
clone()
clone(): Vec
cpr()
cpr(V: VecLike): number
Parameters
Name | Description |
---|---|
|
Returns
number
cross()
cross(V: VecLike): this
Parameters
Name | Description |
---|---|
|
Returns
this
dist()
dist(V: VecLike): number
Parameters
Name | Description |
---|---|
|
Returns
number
distanceToLineSegment()
Parameters
Returns
number
div()
div(t: number): this
Parameters
Name | Description |
---|---|
|
|
Returns
this
divV()
divV(V: VecLike): this
Parameters
Name | Description |
---|---|
|
Returns
this
dpr()
dpr(V: VecLike): number
Parameters
Name | Description |
---|---|
|
Returns
number
equals()
equals(B: VecLike): boolean
Parameters
Name | Description |
---|---|
|
Returns
boolean
equalsXY()
equalsXY(x: number, y: number): boolean
Parameters
Name | Description |
---|---|
|
|
|
|
Returns
boolean
len()
len(): number
len2()
len2(): number
lrp()
Parameters
Name | Description |
---|---|
| |
|
|
Returns
mul()
mul(t: number): this
Parameters
Name | Description |
---|---|
|
|
Returns
this
mulV()
mulV(V: VecLike): this
Parameters
Name | Description |
---|---|
|
Returns
this
neg()
neg(): this
norm()
norm(): this
nudge()
nudge(B: VecLike, distance: number): this
Parameters
Name | Description |
---|---|
| |
|
|
Returns
this
per()
per(): this
pry()
pry(V: VecLike): number
Parameters
Name | Description |
---|---|
|
Returns
number
rot()
rot(r: number): this
Parameters
Name | Description |
---|---|
|
|
Returns
this
rotWith()
rotWith(C: VecLike, r: number): this
Parameters
Name | Description |
---|---|
| |
|
|
Returns
this
set()
set(x?: number, y?: number, z?: number): this
Parameters
Name | Description |
---|---|
|
|
|
|
|
|
Returns
this
setTo()
setTo({ x, y, z }: VecLike): this
Parameters
Name | Description |
---|---|
|
Returns
this
slope()
slope(B: VecLike): number
Parameters
Name | Description |
---|---|
|
Returns
number
snapToGrid()
snapToGrid(gridSize: number): this
Parameters
Name | Description |
---|---|
|
|
Returns
this
sub()
sub(V: VecLike): this
Parameters
Name | Description |
---|---|
|
Returns
this
subScalar()
subScalar(n: number): this
Parameters
Name | Description |
---|---|
|
|
Returns
this
subXY()
subXY(x: number, y: number): this
Parameters
Name | Description |
---|---|
|
|
|
|
Returns
this
tan()
Parameters
Name | Description |
---|---|
|
Returns
toAngle()
toAngle(): number
toArray()
toArray(): number[]
toFixed()
toFixed(): Vec
toJson()
toJson(): VecModel
toString()
toString(): string
uni()
uni(): Vec