Shapemetry API / Vector
Class: Vector
Defined in: core/Vector.ts:6
A 3D direction/displacement (Z-up). Not unit-length unless produced by normalize().
Constructors
Constructor
new Vector(
x,y,z):Vector
Defined in: core/Vector.ts:7
Parameters
x
number
y
number
z
number
Returns
Vector
Properties
x
x:
number
Defined in: core/Vector.ts:7
y
y:
number
Defined in: core/Vector.ts:7
z
z:
number
Defined in: core/Vector.ts:7
Accessors
squaredLength
Get Signature
get squaredLength():
number
Defined in: core/Vector.ts:11
Returns
number
length
Get Signature
get length():
number
Defined in: core/Vector.ts:12
Returns
number
Methods
fromJSON()
staticfromJSON(v):Vector
Defined in: core/Vector.ts:9
Parameters
v
Returns
Vector
isZero()
isZero():
boolean
Defined in: core/Vector.ts:14
Returns
boolean
equals()
equals(
other,tol?):boolean
Defined in: core/Vector.ts:16
Parameters
other
Vector
tol?
number = POINT_COINCIDENCE
Returns
boolean
add()
add(
other):Vector
Defined in: core/Vector.ts:22
Parameters
other
Vector
Returns
Vector
subtract()
subtract(
other):Vector
Defined in: core/Vector.ts:24
Parameters
other
Vector
Returns
Vector
multiplyScalar()
multiplyScalar(
n):Vector
Defined in: core/Vector.ts:26
Parameters
n
number
Returns
Vector
multiplyVector()
multiplyVector(
other):Vector
Defined in: core/Vector.ts:28
Parameters
other
Vector
Returns
Vector
negate()
negate():
Vector
Defined in: core/Vector.ts:30
Returns
Vector
normalize()
normalize():
Vector
Defined in: core/Vector.ts:32
Returns
Vector
dot()
dot(
other):number
Defined in: core/Vector.ts:38
Parameters
other
Vector
Returns
number
cross()
cross(
other):Vector
Defined in: core/Vector.ts:40
Parameters
other
Vector
Returns
Vector
angleTo()
angleTo(
other):number
Defined in: core/Vector.ts:48
Parameters
other
Vector
Returns
number
angleAround()
angleAround(
other,axis):number
Defined in: core/Vector.ts:56
Angle from this to other measured around axis, in range [0, 2p]. axis must be unit.
Parameters
other
Vector
axis
Vector
Returns
number
rotate()
rotate(
axis,rad):Vector
Defined in: core/Vector.ts:63
Rotate this vector by rad around axis (Rodrigues). The axis is normalized internally, so any non-zero axis yields an isometric rotation.
Parameters
axis
Vector
rad
number
Returns
Vector
lerp()
lerp(
other,t):Vector
Defined in: core/Vector.ts:76
Parameters
other
Vector
t
number
Returns
Vector
transform()
transform(
tr):Vector
Defined in: core/Vector.ts:84
Parameters
tr
Returns
Vector
perpendicularTo()
perpendicularTo():
Vector
Defined in: core/Vector.ts:90
Any unit vector perpendicular to this.
Returns
Vector
toJSON()
toJSON():
VectorJSON
Defined in: core/Vector.ts:95