Class: VectorXZUtils
对 VectorXZ 对象执行操作的实用工具类。所有方法均为静态方法,且不会修改输入对象。
Utilities operating on VectorXZ objects. All methods are static and do not modify the input objects.
Constructors
Constructor
new VectorXZUtils():
VectorXZUtils
Returns
VectorXZUtils
Methods
add()
staticadd(v1,v2):VectorXZ
add
将两个向量相加,生成一个新向量。
Add two vectors to produce a new vector
Parameters
v1
VectorXZ
v2
VectorXZ
Returns
VectorXZ
clamp()
staticclamp(v,limits?):VectorXZ
clamp
将向量的各个分量限制在给定范围内,生成一个新向量。
Clamps the components of a vector to limits to produce a new vector
Parameters
v
VectorXZ
limits?
max?
any
min?
any
Returns
VectorXZ
distance()
staticdistance(a,b):number
distance
计算两个向量之间的距离。
Calculate the distance between two vectors
Parameters
a
VectorXZ
b
VectorXZ
Returns
number
dot()
staticdot(a,b):number
dot
计算两个向量的点积。
Calculate the dot product of two vectors
Parameters
a
VectorXZ
b
VectorXZ
Returns
number
equals()
staticequals(v1,v2):boolean
equals
检查两个向量是否相等。
Check the equality of two vectors
Parameters
v1
VectorXZ
v2
VectorXZ
Returns
boolean
floor()
staticfloor(v):VectorXZ
floor
对向量的各个分量向下取整,生成一个新向量。
Floor the components of a vector to produce a new vector
Parameters
v
VectorXZ
Returns
VectorXZ
fromString()
staticfromString(str,delimiter?):any
fromString
从 VectorXZUtils.toString 生成的字符串表示形式中获取 VectorXZ。如果任何数值不是数字,或格式无效,则返回 undefined。
Gets a VectorXZ from the string representation produced by VectorXZUtils.toString. If any numeric value is not a number or the format is invalid, undefined is returned.
Parameters
str
string
要解析的字符串。
The string to parse
delimiter?
string
用于分隔各分量的分隔符。默认为 VectorXZUtils.toString 的默认值。
The delimiter used to separate the components. Defaults to the same as the default for VectorXZUtils.toString
Returns
any
lerp()
staticlerp(a,b,t):VectorXZ
lerp
使用两个向量之间各分量的线性插值构造一个新向量。
Constructs a new vector using linear interpolation on each component from two vectors.
Parameters
a
VectorXZ
b
VectorXZ
t
number
Returns
VectorXZ
magnitude()
staticmagnitude(v):number
magnitude
向量的模长。
The magnitude of a vector
Parameters
v
VectorXZ
Returns
number
multiply()
staticmultiply(a,b):VectorXZ
multiply
两个向量按元素相乘。 不要与 VectorXZUtils.dot 乘积混淆。
Element-wise multiplication of two vectors together. Not to be confused with VectorXZUtils.dot product
Parameters
a
VectorXZ
b
VectorXZ
Returns
VectorXZ
normalize()
staticnormalize(v):VectorXZ
normalize
将向量归一化为单位向量。
Takes a vector 3 and normalizes it to a unit vector
Parameters
v
VectorXZ
Returns
VectorXZ
scale()
staticscale(v1,scale):VectorXZ
scale
将向量的所有分量乘以一个标量,生成一个新向量。
Multiple all entries in a vector by a single scalar value producing a new vector
Parameters
v1
VectorXZ
scale
number
Returns
VectorXZ
slerp()
staticslerp(a,b,t):VectorXZ
slerp
使用两个向量之间各分量的球面线性插值构造一个新向量。
Constructs a new vector using spherical linear interpolation on each component from two vectors.
Parameters
a
VectorXZ
b
VectorXZ
t
number
Returns
VectorXZ
subtract()
staticsubtract(v1,v2):VectorXZ
subtract
将第二个向量从第一个向量中减去,生成一个新向量(v1-v2)。
Subtract two vectors to produce a new vector (v1-v2)
Parameters
v1
VectorXZ
v2
VectorXZ
Returns
VectorXZ
toString()
statictoString(v,options?):string
toString
创建向量的字符串表示形式。
Create a string representation of a vectorxz
Parameters
v
VectorXZ
options?
decimals?
number
delimiter?
string
Returns
string
