Skip to content
Vector

[Basic Type](../groups/Basic Type.Basic Type.md) / Vector

Vector Class

Three-dimensional vector


A vector in three-dimensional space composed of components (x, y, z)

Table of contents

Properties

x: number
X axis coordinate
y: number
Y axis coordinate
z: number
Z-axis coordinate

Accessors

length(): number
The length of a vector
magnitude(a: Vector): number other
Vector length
negative(): Vector
Obtain a new vector with the inverse of each component
normalized(): Vector
Obtain a normalized new vector without affecting the current vector
sqrLength(): number
Square of the length of a vector
sqrMagnitude(a: Vector): number other
Square of vector length
back(): Vector
Vector(-1, 0, 0)
down(): Vector
Vector(0, 0, -1)
forward(): Vector
Vector(1, 0, 0)
left(): Vector
Vector(0, -1, 0)
negOne(): Vector
Vector(-1, -1, -1)
one(): Vector
Vector(1, 1, 1)
right(): Vector
Vector(0, 1, 0)
unitX(): Vector
Vector(1, 0, 0)
unitY(): Vector
Vector(0, 1, 0)
unitZ(): Vector
Vector(0, 0, 1)
up(): Vector
Vector(0, 0, 1)
zero(): Vector
Vector(0, 0, 0)

Methods

add(a: Vector, b: Vector, outer?: Vector): Vector other
Add two vectors together
clone(a: Vector): Vector other
Clone vector a to obtain a new Vector vector
divide(a: Vector, b: Vector, outer?: Vector): Vector other
Divide each component of vector a by scalar b
equals(a: Vector, b: Vector, epsilon?: number): boolean other
Determine whether two vectors are approximately equivalent in excluding floating-point errors
fromString(str: string, outer?: Vector): Vector other
Create a Vector from a string
multiply(a: Vector, b: Vector, outer?: Vector): Vector other
Multiply each component of vector a by scalar b
normalize(a: Vector, outer?: Vector): Vector other
Vector normalization
set(outer: Vector, x: number, y: number, z: number): Vector other
Set the value of the vector
strictEquals(a: Vector, b: Vector): boolean other
Determine if vectors are equal
subtract(a: Vector, b: Vector, outer?: Vector): Vector other
Subtract vector b from vector a
toRotation(): Rotation other
Convert to the corresponding Rotation
toString(): string other
Output as a string
add(a: Vector, b: Vector, outer?: Vector): Vector other
Add two vectors together
angle(a: Vector, b: Vector): number other
The angle between the projection of vector a and vector b on the XY plane
angle3D(a: Vector, b: Vector): number other
The angle between vector a and vector b
ceil(a: Vector, outer?: Vector): Vector other
Each element of vector a is rounded up
clamp(value: Vector, minInclusive: Vector, maxInclusive: Vector): Vector other
Set the value of the current vector so that all its components are within the specified range
clone(a: Vector): Vector other
Clone vector a to obtain a new Vector vector
copy(a: Vector, outer: Vector): Vector other
Obtain a copy of the specified vector
cross(a: Vector, b: Vector, outer?: Vector): Vector other
Cross product
distance(a: Vector, b: Vector): number other
Euclidean distance between two vectors
divide(a: Vector, b: Vector, outer?: Vector): Vector other
Divide each component of vector a by scalar b
dot(a: Vector, b: Vector): number other
Dot product
equals(a: Vector, b: Vector, epsilon?: number): boolean other
Determine whether two vectors are approximately equivalent in excluding floating-point errors
floor(a: Vector, outer?: Vector): Vector other
Rounding down each element of vector a
fromString(str: string, outer?: Vector): Vector other
Create a Vector from a string
invert(a: Vector, outer?: Vector): Vector other
Vector a takes the reciprocal of each element and returns Infinity when it approaches 0
invertSafe(a: Vector, outer?: Vector, epsilon?: number): Vector other
Vector a takes the reciprocal of each element and returns 0 when it approaches 0
lerp(a: Vector, b: Vector, t: number, outer?: Vector): Vector other
Linear interpolation for each element of vector a: a+t * (b-a)
magnitude(a: Vector): number other
Vector length
max(a: Vector, b: Vector, outer?: Vector): Vector other
Take the minimum and maximum values of the x and y elements corresponding to two vectors
min(a: Vector, b: Vector, outer?: Vector): Vector other
Take the minimum value of x and y elements corresponding to two vectors
moveTowards(current: Vector, target: Vector, maxDistanceDelta: number, outer?: Vector): Vector other
Move to the target vector
multiply(a: Vector, b: Vector, outer?: Vector): Vector other
Multiply each component of vector a by scalar b
negate(a: Vector, outer?: Vector): Vector other
Each element of vector a takes a negative value
normalize(a: Vector, outer?: Vector): Vector other
Vector normalization
project(a: Vector, b: Vector, outer?: Vector): Vector other
The projection of vector a onto a specified vector
projectOnPlane(a: Vector, n: Vector, outer?: Vector): Vector other
Projection of vector a on the specified plane
reflect(inDirection: Vector, inNormal: Vector, outer?: Vector): Vector other
reflex
rotateX(v: Vector, o: Vector, a: number, outer?: Vector): Vector other
Rotate the specified radian around the X axis
rotateY(v: Vector, o: Vector, a: number, outer?: Vector): Vector other
Rotate around the Y-axis by a specified arc
rotateZ(v: Vector, o: Vector, a: number, outer?: Vector): Vector other
Rotate the specified radian around the Z axis
round(a: Vector, outer?: Vector): Vector other
Each element is rounded to rounding
set(outer: Vector, x: number, y: number, z: number): Vector other
Set the value of the vector
sqrMagnitude(a: Vector): number other
Square of vector length
squaredDistance(a: Vector, b: Vector): number other
The squared Euclidean distance between two vectors
strictEquals(a: Vector, b: Vector): boolean other
Determine if vectors are equal
subtract(a: Vector, b: Vector, outer?: Vector): Vector other
Subtract vector b from vector a

Construct a new Vector using the given x, y, and z components

Parameters

x? numberUsage: x component default: 0 range: no restrictions type: floating point number
y? numberUsage: y component default: 0 range: no restrictions type: floating point number
z? numberUsage: z-component default: 0 range: no restrictions type: floating point number

new Vector(f)

Set x, y, and z with the given value of f

Parameters

f numberUsage: Given f value range: No restrictions type: Floating point number

new Vector(v)

Set the x, y, and z components of the given Vector value to x, y, and z

Parameters

v VectorUsage: Given Vector

Properties

x

x: number

X axis coordinate


y

y: number

Y axis coordinate


z

z: number

Z-axis coordinate

Accessors

length

get length(): number

The length of a vector

Returns

number

magnitude

get magnitude(): number

The length of a vector

Parameters

a VectorUsage: vector a

Returns

numberVector length

negative

get negative(): Vector

Obtain a new vector with the inverse of each component

Returns

Vector

normalized

get normalized(): Vector

Obtain a normalized new vector without affecting the current vector

Returns

Vector

sqrLength

get sqrLength(): number

Square of the length of a vector

Returns

number

sqrMagnitude

get sqrMagnitude(): number

Square of the length of a vector

Parameters

a VectorUsage: vector a

Returns

numberSquare of vector length

back

Static get back(): Vector

Vector(-1, 0, 0)

Returns

Vector

down

Static get down(): Vector

Vector(0, 0, -1)

Returns

Vector

forward

Static get forward(): Vector

Vector(1, 0, 0)

Returns

Vector

left

Static get left(): Vector

Vector(0, -1, 0)

Returns

Vector

negOne

Static get negOne(): Vector

Vector(-1, -1, -1)

Returns

Vector

one

Static get one(): Vector

Vector(1, 1, 1)

Returns

Vector

Static get right(): Vector

Vector(0, 1, 0)

Returns

Vector

unitX

Static get unitX(): Vector

Vector(1, 0, 0)

Returns

Vector

unitY

Static get unitY(): Vector

Vector(0, 1, 0)

Returns

Vector

unitZ

Static get unitZ(): Vector

Vector(0, 0, 1)

Returns

Vector

up

Static get up(): Vector

Vector(0, 0, 1)

Returns

Vector

zero

Static get zero(): Vector

Vector(0, 0, 0)

Returns

Vector

Methods

add

add(v): Vector other

Add a vector

Parameters

a VectorUsage: vector a
b VectorUsage: vector b
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorThe result of the addition is a Vector object

Parameters

v VectorUsage: vector object for addition

clone

clone(): Vector other

Clone the current vector

Parameters

a VectorUsage: vector a

Returns

VectorThe cloned new Vector object

divide

divide(v): Vector other

Divide by a scalar

Parameters

a VectorUsage: vector a
b numberUsage: vector b
range: unrestricted type: floating-point number
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorVector object resulting from division

Static divide(a, b, outer?): Vector other

Vector a divided by vector b

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)

Parameters

a VectorUsage: vector a
b VectorUsage: vector b
range: unrestricted type: floating-point number
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorVector object resulting from division

Parameters

v numberUsage: parameter divided by each component range: no restrictions type: floating point value
Determine whether the current vector is equal to the specified vector within the error range

Precautions

When the components of two vectors are equal within the specified error range, return true; otherwise, return false

Parameters

other VectorUsage: specified vector
epsilon? numberUsage: Minimum error count default: MathUtil.EPSILON
range: It is recommended to pass in a value less than 1. Type: Floating point number

Returns

booleanIs the current vector equal to the specified vector within the error range

fromString

fromString(str): void other

Read string data

Parameters

str stringUsage: string range to be converted: "0.000000, 0.000000, 0.000000"
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorConverted Vector Object

Parameters

str stringUsage: read character range: "0.000000,0.000000,0.000000"

multiply

multiply(v): Vector other

Multiply by a vector

Parameters

a VectorUsage: vector a
b numberUsage: Scalar b range: Unrestricted type: Floating point number
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorThe result of multiplication is a Vector object

Static multiply(a, b, outer?): Vector other

Multiply vector a by vector b

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)

Parameters

a VectorUsage: vector a
b VectorUsage: vector b
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorThe result of multiplication is a Vector object

Parameters

v VectorUsage: Multiplying vector objects
Normalization of current vector

Returns

VectorNormalized vector

set

set(other): Vector other

Set the current vector to be equal to the specified vector

Parameters

outer VectorUsage: set vector object
x numberx Component range: Unrestricted type: Floating point number
y numbery Component range: Unrestricted type: Floating point number
z numberz Component range: Unrestricted type: Floating point number

Returns

VectorSet Vector Object

set(x?, y?, z?): Vector other

Set the specific component values of the current vector

Parameters

x? numberx Component default: 0 range: No restriction type: Floating point number
y? numbery Component default: 0 range: No restriction type: Floating point number
z? numberz Component default: 0 range: No restriction type: Floating point number

Returns

VectorModified self object

strictEquals

strictEquals(other): boolean other

Determine whether the current vector is equal to the specified vector

Parameters

a VectorUsage: vector a
b VectorUsage: vector b

Returns

booleanAre two vectors equal

| boolean Is the current vector equal to the specified vector | | :------ | :------ |


subtract

subtract(v): Vector other

Subtract a vector

Parameters

a VectorUsage: vector a
b VectorUsage: vector b
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorSubtraction result Vector object

Parameters

v VectorUsage: Subtracting vector objects

toRotation

toRotation(): Rotation other

Convert to the corresponding Rotation

Returns

RotationNew corresponding Rotation object

toString

toString(): string other

Output as a string

Returns

stringVector value string

add

Static add(a, b, outer?): Vector other

Add two vectors together

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)

Parameters

a VectorUsage: vector a
b VectorUsage: vector b
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorThe result of the addition is a Vector object

angle

Static angle(a, b): number other

The angle between the projection of vector a and vector b on the XY plane

Parameters

a VectorUsage: vector a
b VectorUsage: vector b

Returns

numberAngle angle

angle3D

Static angle3D(a, b): number other

The angle between vector a and vector b

Parameters

a VectorUsage: vector a
b VectorUsage: vector b

Returns

numberAngle angle

ceil

Static ceil(a, outer?): Vector other

Each element of vector a is rounded up

Parameters

a VectorUsage: vector a
outer? VectorUsage: receive result vector default: null

Returns

VectorVector object rounding up per element

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


clamp

Static clamp(value, minInclusive, maxInclusive): Vector other

Set the value of the current vector so that all its components are within the specified range

Parameters

value VectorUsage: The value of the current vector
minInclusive VectorUsage: Minimum allowable value
maxInclusive VectorUsage: maximum allowed value

Returns

VectorA vector in which each component is within a specified range

clone

Static clone(a): Vector other

Clone vector a to obtain a new Vector vector

Parameters

a VectorUsage: vector a

Returns

VectorThe cloned new Vector object

copy

Static copy(a, outer): Vector other

Obtain a copy of the specified vector

Parameters

a VectorUsage: target vector
outer VectorUsage: receive result vector default: null

Returns

VectorThe cloned new Vector object

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


cross

Static cross(a, b, outer?): Vector other

Cross product

Parameters

a VectorUsage: vector a
b VectorUsage: vector b
outer? VectorUsage: receive result vector default: null

Returns

VectorCross product Vector object

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


distance

Static distance(a, b): number other

Euclidean distance between two vectors

Parameters

a VectorUsage: vector a
b VectorUsage: vector b

Returns

numberEuclidean distance

divide

Static divide(a, b, outer?): Vector other

Divide each component of vector a by scalar b

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)

Parameters

a VectorUsage: vector a
b numberUsage: vector b
range: unrestricted type: floating-point number
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorVector object resulting from division

Static divide(a, b, outer?): Vector other

Vector a divided by vector b

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)

Parameters

a VectorUsage: vector a
b VectorUsage: vector b
range: unrestricted type: floating-point number
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorVector object resulting from division

dot

Static dot(a, b): number other

Dot product

Parameters

a VectorUsage: vector a
b VectorUsage: vector b

Returns

numberDot product

equals

Static equals(a, b, epsilon?): boolean other

Determine whether two vectors are approximately equivalent in excluding floating-point errors

Parameters

a VectorUsage: vector a
b VectorUsage: vector b
epsilon? numberUsage: Minimum error count default: MathDefine EPSILON
range: It is recommended to pass in a value less than 1. Type: Floating point number

Returns

booleanIs it equivalent

floor

Static floor(a, outer?): Vector other

Rounding down each element of vector a

Parameters

a VectorUsage: vector a
outer? VectorUsage: receive result vector default: null

Returns

VectorVector object rounded down element by element

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


fromString

Static fromString(str, outer?): Vector other

Create a Vector from a string

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)

Parameters

str stringUsage: string range to be converted: "0.000000, 0.000000, 0.000000"
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorConverted Vector Object

invert

Static invert(a, outer?): Vector other

Vector a takes the reciprocal of each element and returns Infinity when it approaches 0

Parameters

a VectorUsage: vector a
outer? VectorUsage: receive result vector default: null

Returns

VectorThe Vector object obtained by taking the reciprocal of each element

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


invertSafe

Static invertSafe(a, outer?, epsilon?): Vector other

Vector a takes the reciprocal of each element and returns 0 when it approaches 0

Parameters

a VectorUsage: vector a
outer? VectorUsage: receive result vector default: null
epsilon? numberUsage: Minimum error count default: MathUtil.EPSILON
range: It is recommended to pass in a value less than 1. Type: Floating point number

Returns

VectorThe Vector object obtained by taking the reciprocal of each element

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


lerp

Static lerp(a, b, t, outer?): Vector other

Linear interpolation for each element of vector a: a+t * (b-a)

Parameters

a VectorUsage: vector a
b VectorUsage: vector b
t numberUsage: Interpolation
range: [0,1] type: Floating point number
outer? VectorUsage: receive result vector default: null

Returns

VectorVector object obtained by linear interpolation

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


magnitude

Static magnitude(a): number other

Vector length

Parameters

a VectorUsage: vector a

Returns

numberVector length

max

Static max(a, b, outer?): Vector other

Take the minimum and maximum values of the x and y elements corresponding to two vectors

Parameters

a VectorUsage: vector a
b VectorUsage: vector b
outer? VectorUsage: receive result vector default: null

Returns

VectorVector object that takes the maximum value element by element

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


min

Static min(a, b, outer?): Vector other

Take the minimum value of x and y elements corresponding to two vectors

Parameters

a VectorUsage: vector a
b VectorUsage: vector b
outer? VectorUsage: receive result vector default: null

Returns

VectorVector object after taking the minimum value element by element

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


moveTowards

Static moveTowards(current, target, maxDistanceDelta, outer?): Vector other

Move to the target vector

Parameters

current VectorUsage: Current vector
target VectorUsage: target vector
maxDistanceDelta numberUsage: maximum moving component
range: unlimited type: floating-point number
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorMoving Vector Object

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


multiply

Static multiply(a, b, outer?): Vector other

Multiply each component of vector a by scalar b

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)

Parameters

a VectorUsage: vector a
b numberUsage: Scalar b range: Unrestricted type: Floating point number
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorThe result of multiplication is a Vector object

Static multiply(a, b, outer?): Vector other

Multiply vector a by vector b

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)

Parameters

a VectorUsage: vector a
b VectorUsage: vector b
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorThe result of multiplication is a Vector object

negate

Static negate(a, outer?): Vector other

Each element of vector a takes a negative value

Parameters

a VectorUsage: vector a
outer? VectorUsage: receive result vector default: null

Returns

VectorVector object after taking negative values element by element

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


normalize

Static normalize(a, outer?): Vector other

Vector normalization

Parameters

a VectorUsage: vector a
outer? VectorUsage: receive result vector default: null

Returns

VectorNormalized Vector Object

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


project

Static project(a, b, outer?): Vector other

The projection of vector a onto a specified vector

Parameters

a VectorUsage: vector a
b VectorUsage: specify the normal of the plane
outer? VectorUsage: Receive projected vector object default: null

Returns

VectorThe projection of vector a onto a specified vector

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


projectOnPlane

Static projectOnPlane(a, n, outer?): Vector other

Projection of vector a on the specified plane

Parameters

a VectorUsage: vector a
n VectorUsage: specify the normal of the plane
outer? VectorUsage: receive result vector default: null

Returns

VectorProjection of vector a on the specified plane

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


reflect

Static reflect(inDirection, inNormal, outer?): Vector other

reflex

Parameters

inDirection VectorUsage: angle of incident vector
inNormal VectorUsage: Normal vector
outer? VectorUsage: receive result vector default: null

Returns

Vectorreflex

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


rotateX

Static rotateX(v, o, a, outer?): Vector other

Rotate the specified radian around the X axis

Parameters

v VectorUsage: Rotation vector
o VectorUsage: Rotation Center
a numberUsage: Rotation radius range: No restrictions type: Floating point number
outer? VectorUsage: receive result vector default: null

Returns

VectorVector object after rotating the specified radians about the X axis

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


rotateY

Static rotateY(v, o, a, outer?): Vector other

Rotate around the Y-axis by a specified arc

Parameters

v VectorUsage: Rotation vector
o VectorUsage: Rotation Center
a numberUsage: Rotation radius range: No restrictions type: Floating point number
outer? VectorUsage: receive result vector default: null

Returns

VectorVector object after rotating the specified radians around the Y axis

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


rotateZ

Static rotateZ(v, o, a, outer?): Vector other

Rotate the specified radian around the Z axis

Parameters

v VectorUsage: Rotation vector
o VectorUsage: Rotation Center
a numberUsage: Rotation radius range: No restrictions type: Floating point number
outer? VectorUsage: receive result vector default: null

Returns

VectorRotate the Vector object around the Z-axis by a specified arc

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


round

Static round(a, outer?): Vector other

Each element is rounded to rounding

Parameters

a VectorUsage: vector a
outer? VectorUsage: receive result vector default: null

Returns

VectorVector object after rounding element by element

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)


set

Static set(outer, x, y, z): Vector other

Set the value of the vector

Parameters

outer VectorUsage: set vector object
x numberx Component range: Unrestricted type: Floating point number
y numbery Component range: Unrestricted type: Floating point number
z numberz Component range: Unrestricted type: Floating point number

Returns

VectorSet Vector Object

sqrMagnitude

Static sqrMagnitude(a): number other

Square of vector length

Parameters

a VectorUsage: vector a

Returns

numberSquare of vector length

squaredDistance

Static squaredDistance(a, b): number other

The squared Euclidean distance between two vectors

Parameters

a VectorUsage: vector a
b VectorUsage: vector b

Returns

numberSquared Euclidean distance

strictEquals

Static strictEquals(a, b): boolean other

Determine if vectors are equal

Parameters

a VectorUsage: vector a
b VectorUsage: vector b

Returns

booleanAre two vectors equal

subtract

Static subtract(a, b, outer?): Vector other

Subtract vector b from vector a

outer It is an optional parameter. The function is that when an outer is passed in, the calculation result will be assigned to the outer. (The incoming outer vector cannot be null/undefined)

Parameters

a VectorUsage: vector a
b VectorUsage: vector b
outer? VectorUsage: Vector object for receiving results default: null

Returns

VectorSubtraction result Vector object