Vec
Table of contents
- Properties
- Methods
- abs
- Abs
- add
- Add
- addScalar
- AddScalar
- addXY
- AddXY
- angle
- Angle
- Average
- Cast
- clamp
- Clamp
- Clockwise
- clone
- cpr
- Cpr
- cross
- Cross
- dist
- Dist
- Dist2
- distanceToLineSegment
- DistanceToLineSegment
- DistanceToLineThroughPoint
- div
- Div
- divV
- DivV
- dpr
- Dpr
- equals
- Equals
- equalsXY
- EqualsXY
- From
- FromAngle
- FromArray
- len
- Len
- len2
- Len2
- lrp
- Lrp
- Max
- Med
- Min
- mul
- Mul
- mulV
- MulV
- NearestPointOnLineSegment
- NearestPointOnLineThroughPoint
- neg
- Neg
- norm
- nudge
- Nudge
- per
- Per
- PointsBetween
- pry
- Pry
- Rescale
- rot
- Rot
- rotWith
- RotWith
- ScaleWithOrigin
- set
- setTo
- slope
- Slope
- Snap
- snapToGrid
- SnapToGrid
- sub
- Sub
- subScalar
- SubScalar
- subXY
- SubXY
- tan
- Tan
- toAngle
- ToAngle
- toArray
- ToArray
- toFixed
- ToFixed
- toJson
- ToJson
- toString
- ToString
- uni
- Uni
Public class
class Vec {}
packages/editor/src/lib/primitives/Vec.ts
Constructor
Public constructor
Constructs a new instance of the Vec
class
Name | Description |
---|---|
|
|
|
|
|
|
Properties
pressure
Public readonly property
get pressure(): number
x
Public property
x: number
y
Public property
y: number
z
Public property
z: number
Methods
abs()
Public method
abs(): this
Abs()
Public static method
static Abs(A: VecLike): Vec
Name | Description |
---|---|
|
|
Vec
add()
Public method
add(V: VecLike): this
Name | Description |
---|---|
|
|
this
Add()
Public static method
static Add(A: VecLike, B: VecLike): Vec
Name | Description |
---|---|
|
|
|
|
Vec
addScalar()
Public method
addScalar(n: number): this
Name | Description |
---|---|
|
|
this
AddScalar()
Public static method
static AddScalar(A: VecLike, n: number): Vec
Name | Description |
---|---|
|
|
|
|
Vec
addXY()
Public method
addXY(x: number, y: number): this
Name | Description |
---|---|
|
|
|
|
this
AddXY()
Public static method
static AddXY(A: VecLike, x: number, y: number): Vec
Name | Description |
---|---|
|
|
|
|
|
|
Vec
angle()
Public method
angle(B: VecLike): number
Name | Description |
---|---|
|
|
number
Angle()
Public static method
static Angle(A: VecLike, B: VecLike): number
Name | Description |
---|---|
|
|
|
|
number
Average()
Public static method
static Average(arr: VecLike[]): Vec
Name | Description |
---|---|
|
|
Vec
Cast()
Public static method
static Cast(A: VecLike): Vec
Name | Description |
---|---|
|
|
Vec
clamp()
Public method
clamp(min: number, max?: number): this
Name | Description |
---|---|
|
|
|
|
this
Clamp()
Public static method
static Clamp(A: Vec, min: number, max?: number): Vec
Name | Description |
---|---|
|
|
|
|
|
|
Vec
Clockwise()
Public static method
static Clockwise(A: VecLike, B: VecLike, C: VecLike): boolean
Name | Description |
---|---|
|
|
|
|
|
|
boolean
clone()
Public method
clone(): Vec
cpr()
Public method
cpr(V: VecLike): number
Name | Description |
---|---|
|
|
number
Cpr()
Public static method
Cross product of two vectors which is used to calculate the area of a parallelogram.
static Cpr(A: VecLike, B: VecLike): number
Name | Description |
---|---|
|
|
|
|
number
cross()
Public method
cross(V: VecLike): this
Name | Description |
---|---|
|
|
this
Cross()
Public static method
static Cross(A: VecLike, V: VecLike): Vec
Name | Description |
---|---|
|
|
|
|
Vec
dist()
Public method
dist(V: VecLike): number
Name | Description |
---|---|
|
|
number
Dist()
Public static method
static Dist(A: VecLike, B: VecLike): number
Name | Description |
---|---|
|
|
|
|
number
Dist2()
Public static method
static Dist2(A: VecLike, B: VecLike): number
Name | Description |
---|---|
|
|
|
|
number
distanceToLineSegment()
Public method
distanceToLineSegment(A: VecLike, B: VecLike): number
Name | Description |
---|---|
|
|
|
|
number
DistanceToLineSegment()
Public static method
static DistanceToLineSegment(
A: VecLike,
B: VecLike,
P: VecLike,
clamp?: boolean
): number
Name | Description |
---|---|
|
|
|
|
|
|
|
|
number
DistanceToLineThroughPoint()
Public static method
static DistanceToLineThroughPoint(A: VecLike, u: VecLike, P: VecLike): number
Name | Description |
---|---|
|
|
|
|
|
|
number
div()
Public method
div(t: number): this
Name | Description |
---|---|
|
|
this
Div()
Public static method
static Div(A: VecLike, t: number): Vec
Name | Description |
---|---|
|
|
|
|
Vec
divV()
Public method
divV(V: VecLike): this
Name | Description |
---|---|
|
|
this
DivV()
Public static method
static DivV(A: VecLike, B: VecLike): Vec
Name | Description |
---|---|
|
|
|
|
Vec
dpr()
Public method
dpr(V: VecLike): number
Name | Description |
---|---|
|
|
number
Dpr()
Public static method
Dot product of two vectors which is used to calculate the angle between them.
static Dpr(A: VecLike, B: VecLike): number
Name | Description |
---|---|
|
|
|
|
number
equals()
Public method
equals(B: VecLike): boolean
Name | Description |
---|---|
|
|
boolean
Equals()
Public static method
static Equals(A: VecLike, B: VecLike): boolean
Name | Description |
---|---|
|
|
|
|
boolean
equalsXY()
Public method
equalsXY(x: number, y: number): boolean
Name | Description |
---|---|
|
|
|
|
boolean
EqualsXY()
Public static method
static EqualsXY(A: VecLike, x: number, y: number): boolean
Name | Description |
---|---|
|
|
|
|
|
|
boolean
From()
Public static method
static From({ x, y, z }: VecModel): Vec
Name | Description |
---|---|
|
|
Vec
FromAngle()
Public static method
static FromAngle(r: number, length?: number): Vec
Name | Description |
---|---|
|
|
|
|
Vec
FromArray()
Public static method
static FromArray(v: number[]): Vec
Name | Description |
---|---|
|
|
Vec
len()
Public method
len(): number
Len()
Public static method
static Len(A: VecLike): number
Name | Description |
---|---|
|
|
number
len2()
Public method
len2(): number
Len2()
Public static method
static Len2(A: VecLike): number
Name | Description |
---|---|
|
|
number
lrp()
Public method
lrp(B: VecLike, t: number): Vec
Name | Description |
---|---|
|
|
|
|
Vec
Lrp()
Public static method
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.
Max()
Public static method
static Max(A: VecLike, B: VecLike): Vec
Name | Description |
---|---|
|
|
|
|
Vec
Med()
Public static method
static Med(A: VecLike, B: VecLike): Vec
Name | Description |
---|---|
|
|
|
|
Vec
Min()
Public static method
static Min(A: VecLike, B: VecLike): Vec
Name | Description |
---|---|
|
|
|
|
Vec
mul()
Public method
mul(t: number): this
Name | Description |
---|---|
|
|
this
Mul()
Public static method
static Mul(A: VecLike, t: number): Vec
Name | Description |
---|---|
|
|
|
|
Vec
mulV()
Public method
mulV(V: VecLike): this
Name | Description |
---|---|
|
|
this
MulV()
Public static method
static MulV(A: VecLike, B: VecLike): Vec
Name | Description |
---|---|
|
|
|
|
Vec
NearestPointOnLineSegment()
Public static method
static NearestPointOnLineSegment(
A: VecLike,
B: VecLike,
P: VecLike,
clamp?: boolean
): Vec
Name | Description |
---|---|
|
|
|
|
|
|
|
|
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)
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
neg()
Public method
neg(): this
Neg()
Public static method
static Neg(A: VecLike): Vec
Name | Description |
---|---|
|
|
Vec
norm()
Public method
norm(): this
nudge()
Public method
nudge(B: VecLike, distance: number): this
Name | Description |
---|---|
|
|
|
|
this
Nudge()
Public static method
static Nudge(A: VecLike, B: VecLike, distance: number): Vec
Name | Description |
---|---|
|
|
|
|
|
|
Vec
per()
Public method
per(): this
Per()
Public static method
Get the perpendicular vector to A.
static Per(A: VecLike): Vec
Name | Description |
---|---|
|
|
Vec
PointsBetween()
Public static method
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[]
pry()
Public method
pry(V: VecLike): number
Name | Description |
---|---|
|
|
number
Pry()
Public static method
Get the projection of A onto B.
static Pry(A: VecLike, B: VecLike): number
Name | Description |
---|---|
|
|
|
|
number
Rescale()
Public static method
static Rescale(A: VecLike, n: number): Vec
Name | Description |
---|---|
|
|
|
|
Vec
rot()
Public method
rot(r: number): this
Name | Description |
---|---|
|
|
this
Rot()
Public static method
static Rot(A: VecLike, r?: number): Vec
Name | Description |
---|---|
|
|
|
|
Vec
rotWith()
Public method
rotWith(C: VecLike, r: number): this
Name | Description |
---|---|
|
|
|
|
this
RotWith()
Public static method
static RotWith(A: VecLike, C: VecLike, r: number): Vec
Name | Description |
---|---|
|
|
|
|
|
|
Vec
ScaleWithOrigin()
Public static method
static ScaleWithOrigin(A: VecLike, scale: number, origin: VecLike): Vec
Name | Description |
---|---|
|
|
|
|
|
|
Vec
set()
Public method
set(x?: number, y?: number, z?: number): this
Name | Description |
---|---|
|
|
|
|
|
|
this
setTo()
Public method
setTo({ x, y, z }: VecLike): this
Name | Description |
---|---|
|
|
this
slope()
Public method
slope(B: VecLike): number
Name | Description |
---|---|
|
|
number
Slope()
Public static method
static Slope(A: VecLike, B: VecLike): number
Name | Description |
---|---|
|
|
|
|
number
Snap()
Public static method
static Snap(A: VecLike, step?: number): Vec
Name | Description |
---|---|
|
|
|
|
Vec
snapToGrid()
Public method
snapToGrid(gridSize: number): this
Name | Description |
---|---|
|
|
this
SnapToGrid()
Public static method
static SnapToGrid(A: VecLike, gridSize?: number): Vec
Name | Description |
---|---|
|
|
|
|
Vec
sub()
Public method
sub(V: VecLike): this
Name | Description |
---|---|
|
|
this
Sub()
Public static method
static Sub(A: VecLike, B: VecLike): Vec
Name | Description |
---|---|
|
|
|
|
Vec
subScalar()
Public method
subScalar(n: number): this
Name | Description |
---|---|
|
|
this
SubScalar()
Public static method
static SubScalar(A: VecLike, n: number): Vec
Name | Description |
---|---|
|
|
|
|
Vec
subXY()
Public method
subXY(x: number, y: number): this
Name | Description |
---|---|
|
|
|
|
this
SubXY()
Public static method
static SubXY(A: VecLike, x: number, y: number): Vec
Name | Description |
---|---|
|
|
|
|
|
|
Vec
tan()
Public method
tan(V: VecLike): Vec
Name | Description |
---|---|
|
|
Vec
Tan()
Public static method
static Tan(A: VecLike, B: VecLike): Vec
Name | Description |
---|---|
|
|
|
|
Vec
toAngle()
Public method
toAngle(): number
ToAngle()
Public static method
static ToAngle(A: VecLike): number
Name | Description |
---|---|
|
|
number
toArray()
Public method
toArray(): number[]
ToArray()
Public static method
static ToArray(A: VecLike): number[]
Name | Description |
---|---|
|
|
number[]
toFixed()
Public method
toFixed(): Vec
ToFixed()
Public static method
static ToFixed(A: VecLike, n?: number): Vec
Name | Description |
---|---|
|
|
|
|
Vec
toJson()
Public method
toJson(): VecModel
ToJson()
Public static method
static ToJson(A: VecLike): {
x: number
y: number
z: number | undefined
}
Name | Description |
---|---|
|
|
{
x: number
y: number
z: number | undefined
}
toString()
Public method
toString(): string
ToString()
Public static method
static ToString(A: VecLike): string
Name | Description |
---|---|
|
|
string
uni()
Public method
uni(): Vec
Uni()
Public static method
Get the unit vector of A.
static Uni(A: VecLike): Vec
Name | Description |
---|---|
|
|
Vec