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