Vec2d
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 Vec2d {}
packages/editor/src/lib/primitives/Vec2d.ts
Constructor
Public constructor
Constructs a new instance of the Vec2d
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): Vec2d
Name | Description |
---|---|
|
|
Vec2d
add()
Public method
add(V: VecLike): this
Name | Description |
---|---|
|
|
this
Add()
Public static method
static Add(A: VecLike, B: VecLike): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
addScalar()
Public method
addScalar(n: number): this
Name | Description |
---|---|
|
|
this
AddScalar()
Public static method
static AddScalar(A: VecLike, n: number): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
addXY()
Public method
addXY(x: number, y: number): this
Name | Description |
---|---|
|
|
|
|
this
AddXY()
Public static method
static AddXY(A: VecLike, x: number, y: number): Vec2d
Name | Description |
---|---|
|
|
|
|
|
|
Vec2d
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[]): Vec2d
Name | Description |
---|---|
|
|
Vec2d
Cast()
Public static method
static Cast(A: VecLike): Vec2d
Name | Description |
---|---|
|
|
Vec2d
clamp()
Public method
clamp(min: number, max?: number): this
Name | Description |
---|---|
|
|
|
|
this
Clamp()
Public static method
static Clamp(A: Vec2d, min: number, max?: number): Vec2d
Name | Description |
---|---|
|
|
|
|
|
|
Vec2d
Clockwise()
Public static method
static Clockwise(A: VecLike, B: VecLike, C: VecLike): boolean
Name | Description |
---|---|
|
|
|
|
|
|
boolean
clone()
Public method
clone(): Vec2d
cpr()
Public method
cpr(V: VecLike): number
Name | Description |
---|---|
|
|
number
Cpr()
Public static method
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): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
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): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
divV()
Public method
divV(V: VecLike): this
Name | Description |
---|---|
|
|
this
DivV()
Public static method
static DivV(A: VecLike, B: VecLike): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
dpr()
Public method
dpr(V: VecLike): number
Name | Description |
---|---|
|
|
number
Dpr()
Public static method
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 }: Vec2dModel): Vec2d
Name | Description |
---|---|
|
|
Vec2d
FromAngle()
Public static method
static FromAngle(r: number, length?: number): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
FromArray()
Public static method
static FromArray(v: number[]): Vec2d
Name | Description |
---|---|
|
|
Vec2d
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): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
Lrp()
Public static method
static Lrp(A: VecLike, B: VecLike, t: number): Vec2d
Name | Description |
---|---|
|
|
|
|
|
|
Vec2d
Max()
Public static method
static Max(A: VecLike, B: VecLike): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
Med()
Public static method
static Med(A: VecLike, B: VecLike): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
Min()
Public static method
static Min(A: VecLike, B: VecLike): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
mul()
Public method
mul(t: number): this
Name | Description |
---|---|
|
|
this
Mul()
Public static method
static Mul(A: VecLike, t: number): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
mulV()
Public method
mulV(V: VecLike): this
Name | Description |
---|---|
|
|
this
MulV()
Public static method
static MulV(A: VecLike, B: VecLike): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
NearestPointOnLineSegment()
Public static method
static NearestPointOnLineSegment(
A: VecLike,
B: VecLike,
P: VecLike,
clamp?: boolean
): Vec2d
Name | Description |
---|---|
|
|
|
|
|
|
|
|
Vec2d
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
): Vec2d
Name | Description |
---|---|
|
Any point on the line |
|
The unit vector for the line. |
|
A point not on the line to test. |
Vec2d
neg()
Public method
neg(): this
Neg()
Public static method
static Neg(A: VecLike): Vec2d
Name | Description |
---|---|
|
|
Vec2d
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): Vec2d
Name | Description |
---|---|
|
|
|
|
|
|
Vec2d
per()
Public method
per(): this
Per()
Public static method
static Per(A: VecLike): Vec2d
Name | Description |
---|---|
|
|
Vec2d
PointsBetween()
Public static method
Get an array of points (with simulated pressure) between two points.
static PointsBetween(A: Vec2dModel, B: Vec2dModel, steps?: number): Vec2d[]
Name | Description |
---|---|
|
The first point. |
|
The second point. |
|
The number of points to return. |
Vec2d[]
pry()
Public method
pry(V: VecLike): number
Name | Description |
---|---|
|
|
number
Pry()
Public static method
static Pry(A: VecLike, B: VecLike): number
Name | Description |
---|---|
|
|
|
|
number
Rescale()
Public static method
static Rescale(A: VecLike, n: number): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
rot()
Public method
rot(r: number): this
Name | Description |
---|---|
|
|
this
Rot()
Public static method
static Rot(A: VecLike, r?: number): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
rotWith()
Public method
rotWith(C: VecLike, r: number): this
Name | Description |
---|---|
|
|
|
|
this
RotWith()
Public static method
static RotWith(A: VecLike, C: VecLike, r: number): Vec2d
Name | Description |
---|---|
|
|
|
|
|
|
Vec2d
ScaleWithOrigin()
Public static method
static ScaleWithOrigin(A: VecLike, scale: number, origin: VecLike): Vec2d
Name | Description |
---|---|
|
|
|
|
|
|
Vec2d
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): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
snapToGrid()
Public method
snapToGrid(gridSize: number): this
Name | Description |
---|---|
|
|
this
SnapToGrid()
Public static method
static SnapToGrid(A: VecLike, gridSize?: number): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
sub()
Public method
sub(V: VecLike): this
Name | Description |
---|---|
|
|
this
Sub()
Public static method
static Sub(A: VecLike, B: VecLike): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
subScalar()
Public method
subScalar(n: number): this
Name | Description |
---|---|
|
|
this
SubScalar()
Public static method
static SubScalar(A: VecLike, n: number): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
subXY()
Public method
subXY(x: number, y: number): this
Name | Description |
---|---|
|
|
|
|
this
SubXY()
Public static method
static SubXY(A: VecLike, x: number, y: number): Vec2d
Name | Description |
---|---|
|
|
|
|
|
|
Vec2d
tan()
Public method
tan(V: VecLike): Vec2d
Name | Description |
---|---|
|
|
Vec2d
Tan()
Public static method
static Tan(A: VecLike, B: VecLike): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
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(): Vec2d
ToFixed()
Public static method
static ToFixed(A: VecLike, n?: number): Vec2d
Name | Description |
---|---|
|
|
|
|
Vec2d
toJson()
Public method
toJson(): Vec2dModel
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(): Vec2d
Uni()
Public static method
static Uni(A: VecLike): Vec2d
Name | Description |
---|---|
|
|
Vec2d