[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? number | Usage: x component default: 0 range: no restrictions type: floating point number |
---|---|
y? number | Usage: y component default: 0 range: no restrictions type: floating point number |
z? number | Usage: 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 number | Usage: 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 Vector | Usage: Given Vector |
---|
Properties
x
• x: number
X axis coordinate
y
• y: number
Y axis coordinate
z
• z: number
Z-axis coordinate
Accessors
length
• | ||
---|---|---|
The length of a vector Returns
|
magnitude
• get
magnitude(): number
The length of a vector
Parameters
a Vector | Usage: vector a |
---|
Returns
number | Vector length |
---|
negative
• | ||
---|---|---|
Obtain a new vector with the inverse of each component Returns
|
normalized
• | ||
---|---|---|
Obtain a normalized new vector without affecting the current vector Returns
|
sqrLength
• | ||
---|---|---|
Square of the length of a vector Returns
|
sqrMagnitude
• get
sqrMagnitude(): number
Square of the length of a vector
Parameters
a Vector | Usage: vector a |
---|
Returns
number | Square of vector length |
---|
back
• | ||
---|---|---|
Vector(-1, 0, 0) Returns
|
down
• | ||
---|---|---|
Vector(0, 0, -1) Returns
|
forward
• | ||
---|---|---|
Vector(1, 0, 0) Returns
|
left
• | ||
---|---|---|
Vector(0, -1, 0) Returns
|
negOne
• | ||
---|---|---|
Vector(-1, -1, -1) Returns
|
one
• | ||
---|---|---|
Vector(1, 1, 1) Returns
|
right
• | ||
---|---|---|
Vector(0, 1, 0) Returns
|
unitX
• | ||
---|---|---|
Vector(1, 0, 0) Returns
|
unitY
• | ||
---|---|---|
Vector(0, 1, 0) Returns
|
unitZ
• | ||
---|---|---|
Vector(0, 0, 1) Returns
|
up
• | ||
---|---|---|
Vector(0, 0, 1) Returns
|
zero
• |
---|
Vector(0, 0, 0) Returns |
Vector |
---|
Methods
add
• add(v
): Vector
other
Add a vector
Parameters
a Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | The result of the addition is a Vector object |
---|
Parameters
v Vector | Usage: vector object for addition |
---|
clone
• clone(): Vector
other
Clone the current vector
Parameters
a Vector | Usage: vector a |
---|
Returns
Vector | The cloned new Vector object |
---|
divide
• divide(v
): Vector
other
Divide by a scalar
Parameters
a Vector | Usage: vector a |
---|---|
b number | Usage: vector b range: unrestricted type: floating-point number |
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | Vector 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 Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b range: unrestricted type: floating-point number |
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | Vector object resulting from division |
---|
Parameters
v number | Usage: 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 Vector | Usage: specified vector |
---|---|
epsilon? number | Usage: Minimum error count default: MathUtil.EPSILON range: It is recommended to pass in a value less than 1. Type: Floating point number |
Returns
boolean | Is the current vector equal to the specified vector within the error range |
---|
fromString
• fromString(str
): void
other
Read string data
Parameters
str string | Usage: string range to be converted: "0.000000, 0.000000, 0.000000" |
---|---|
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | Converted Vector Object |
---|
Parameters
str string | Usage: read character range: "0.000000,0.000000,0.000000" |
---|
multiply
• multiply(v
): Vector
other
Multiply by a vector
Parameters
a Vector | Usage: vector a |
---|---|
b number | Usage: Scalar b range: Unrestricted type: Floating point number |
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | The 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 Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | The result of multiplication is a Vector object |
---|
Parameters
v Vector | Usage: Multiplying vector objects |
---|---|
Normalization of current vector |
Returns
Vector | Normalized vector |
---|
set
• set(other
): Vector
other
Set the current vector to be equal to the specified vector
Parameters
outer Vector | Usage: set vector object |
---|---|
x number | x Component range: Unrestricted type: Floating point number |
y number | y Component range: Unrestricted type: Floating point number |
z number | z Component range: Unrestricted type: Floating point number |
Returns
Vector | Set Vector Object |
---|
• set(x?
, y?
, z?
): Vector
other
Set the specific component values of the current vector
Parameters
x? number | x Component default: 0 range: No restriction type: Floating point number |
---|---|
y? number | y Component default: 0 range: No restriction type: Floating point number |
z? number | z Component default: 0 range: No restriction type: Floating point number |
Returns
Vector | Modified self object |
---|
strictEquals
• strictEquals(other
): boolean
other
Determine whether the current vector is equal to the specified vector
Parameters
a Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
Returns
boolean | Are two vectors equal |
---|
| boolean
Is the current vector equal to the specified vector | | :------ | :------ |
subtract
• subtract(v
): Vector
other
Subtract a vector
Parameters
a Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | Subtraction result Vector object |
---|
Parameters
v Vector | Usage: Subtracting vector objects |
---|
toRotation
• toRotation(): Rotation
other
Convert to the corresponding Rotation
Returns
Rotation | New corresponding Rotation object |
---|
toString
• toString(): string
other
Output as a string
Returns
string | Vector 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 Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | The 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 Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
Returns
number | Angle angle |
---|
angle3D
• Static
angle3D(a
, b
): number
other
The angle between vector a and vector b
Parameters
a Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
Returns
number | Angle angle |
---|
ceil
• Static
ceil(a
, outer?
): Vector
other
Each element of vector a is rounded up
Parameters
a Vector | Usage: vector a |
---|---|
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | Vector 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 Vector | Usage: The value of the current vector |
---|---|
minInclusive Vector | Usage: Minimum allowable value |
maxInclusive Vector | Usage: maximum allowed value |
Returns
Vector | A 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 Vector | Usage: vector a |
---|
Returns
Vector | The cloned new Vector object |
---|
copy
• Static
copy(a
, outer
): Vector
other
Obtain a copy of the specified vector
Parameters
a Vector | Usage: target vector |
---|---|
outer Vector | Usage: receive result vector default: null |
Returns
Vector | The 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 Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | Cross 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 Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
Returns
number | Euclidean 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 Vector | Usage: vector a |
---|---|
b number | Usage: vector b range: unrestricted type: floating-point number |
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | Vector 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 Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b range: unrestricted type: floating-point number |
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | Vector object resulting from division |
---|
dot
• Static
dot(a
, b
): number
other
Dot product
Parameters
a Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
Returns
number | Dot product |
---|
equals
• Static
equals(a
, b
, epsilon?
): boolean
other
Determine whether two vectors are approximately equivalent in excluding floating-point errors
Parameters
a Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
epsilon? number | Usage: Minimum error count default: MathDefine EPSILON range: It is recommended to pass in a value less than 1. Type: Floating point number |
Returns
boolean | Is it equivalent |
---|
floor
• Static
floor(a
, outer?
): Vector
other
Rounding down each element of vector a
Parameters
a Vector | Usage: vector a |
---|---|
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | Vector 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 string | Usage: string range to be converted: "0.000000, 0.000000, 0.000000" |
---|---|
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | Converted 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 Vector | Usage: vector a |
---|---|
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | The 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 Vector | Usage: vector a |
---|---|
outer? Vector | Usage: receive result vector default: null |
epsilon? number | Usage: Minimum error count default: MathUtil.EPSILON range: It is recommended to pass in a value less than 1. Type: Floating point number |
Returns
Vector | The 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 Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
t number | Usage: Interpolation range: [0,1] type: Floating point number |
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | Vector 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 Vector | Usage: vector a |
---|
Returns
number | Vector 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 Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | Vector 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 Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | Vector 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 Vector | Usage: Current vector |
---|---|
target Vector | Usage: target vector |
maxDistanceDelta number | Usage: maximum moving component range: unlimited type: floating-point number |
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | Moving 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 Vector | Usage: vector a |
---|---|
b number | Usage: Scalar b range: Unrestricted type: Floating point number |
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | The 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 Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | The 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 Vector | Usage: vector a |
---|---|
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | Vector 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 Vector | Usage: vector a |
---|---|
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | Normalized 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 Vector | Usage: vector a |
---|---|
b Vector | Usage: specify the normal of the plane |
outer? Vector | Usage: Receive projected vector object default: null |
Returns
Vector | The 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 Vector | Usage: vector a |
---|---|
n Vector | Usage: specify the normal of the plane |
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | Projection 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 Vector | Usage: angle of incident vector |
---|---|
inNormal Vector | Usage: Normal vector |
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | reflex |
---|
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 Vector | Usage: Rotation vector |
---|---|
o Vector | Usage: Rotation Center |
a number | Usage: Rotation radius range: No restrictions type: Floating point number |
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | Vector 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 Vector | Usage: Rotation vector |
---|---|
o Vector | Usage: Rotation Center |
a number | Usage: Rotation radius range: No restrictions type: Floating point number |
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | Vector 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 Vector | Usage: Rotation vector |
---|---|
o Vector | Usage: Rotation Center |
a number | Usage: Rotation radius range: No restrictions type: Floating point number |
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | Rotate 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 Vector | Usage: vector a |
---|---|
outer? Vector | Usage: receive result vector default: null |
Returns
Vector | Vector 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 Vector | Usage: set vector object |
---|---|
x number | x Component range: Unrestricted type: Floating point number |
y number | y Component range: Unrestricted type: Floating point number |
z number | z Component range: Unrestricted type: Floating point number |
Returns
Vector | Set Vector Object |
---|
sqrMagnitude
• Static
sqrMagnitude(a
): number
other
Square of vector length
Parameters
a Vector | Usage: vector a |
---|
Returns
number | Square of vector length |
---|
squaredDistance
• Static
squaredDistance(a
, b
): number
other
The squared Euclidean distance between two vectors
Parameters
a Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
Returns
number | Squared Euclidean distance |
---|
strictEquals
• Static
strictEquals(a
, b
): boolean
other
Determine if vectors are equal
Parameters
a Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
Returns
boolean | Are 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 Vector | Usage: vector a |
---|---|
b Vector | Usage: vector b |
outer? Vector | Usage: Vector object for receiving results default: null |
Returns
Vector | Subtraction result Vector object |
---|