Vector3 三维向量
Struct
Representation of 3D vectors and points.
表示3D的向量和点。
This structure is used throughout Unity to pass 3D positions and directions around. It also contains functions for doing common vector operations.
这个结构用于在Unity传递3D位置和方向。它也包含做些普通向量运算的函数。
Besides the functions listed below, other classes can be used to manipulate vectors and points as well. For example the Quaternion and the Matrix4x4 classes are useful for rotating or transforming vectors and points.
除了下面列出的函数,其他类用于处理向量和点。例如Quaternion和Matrix4x4类用于旋转或变换向量和点。
Variables变量
-
x
X component of the vector.
向量的X组件。 -
y
Y component of the vector.
向量的Y组件。 -
z
Z component of the vector.
向量的Z组件。 -
this [int index]
Access the x, y, z components using [0], [1], [2] respectively.
使用[0], [1], [2]分别访问组件x, y, z组件。简单来说就是用索引号代替x, y, z组件。 -
normalized
Returns this vector with a magnitude of 1 (Read Only).
返回向量的长度为1(只读)。 -
magnitude
Returns the length of this vector (Read Only).
返回向量的长度(只读)。 -
sqrMagnitude
Returns the squared length of this vector (Read Only).
返回这个向量的长度的平方(只读)。
Constructors构造器
-
Vector3
Creates a new vector with given x, y, z components.
创建一个新的具有给定x, y, z组件的向量。
Functions函数
-
Scale
Multiplies every component of this vector by the same component of scale.
由缩放的相同的组件对应乘以这个矢量的每个组件。 -
Normalize
Makes this vector have a magnitude of 1.
使向量的长度为1。 -
ToString
Returns a nicely formatted string for this vector.
返回此向量格式化的字符串。
Class Variables类变量
-
zero
Shorthand for writing Vector3(0,
0, 0)
写Vector3(0, 0, 0)的简码。 -
one
Shorthand for writing Vector3(1,
1, 1)
写Vector3(1, 1, 1)的简码。 -
forward
Shorthand for writing Vector3(0,
0, 1)
写Vector3(0, 0, 1)的简码,也就是向z轴。 -
up
Shorthand for writing Vector3(0,
1, 0)
写Vector3(0, 1, 0)的简码,也就是向y轴。 -
right
Shorthand for writing Vector3(1,
0, 0)
写Vector3(1, 0, 0)的简码,也就是向x轴。
Class Functions类函数
-
Lerp
Linearly interpolates between two vectors.
两个向量之间的线性插值。 -
Slerp
Spherically interpolates between two vectors.
球形插值在两个向量之间。 -
OrthoNormalize
Makes vectors normalized and orthogonal to each other.
使向量规范化并且彼此相互垂直。 -
MoveTowards
Moves a point current towards target.
当前的地点移向目标。 -
RotateTowards
Rotates a vector current towards target.
当前的向量转向目标。 -
SmoothDamp
Gradually changes a vector towards a desired goal over time.
随着时间的推移,逐渐改变一个向量朝向预期的目标。 -
Scale
Multiplies two vectors component-wise.
两个矢量组件对应相乘。 -
Cross
Cross Product of two vectors.
两个向量的交叉乘积。返回lhs x rhs -
Reflect
Reflects the vector along the normal.
沿着法线反射向量。 -
Dot
Dot Product of two vectors.
两个向量的点乘积。 -
Project
Projects a vector onto another vector.
投影一个向量到另一个向量。 -
Angle
Returns the angle in degrees between from and to.
由from和to两者返回一个角度。 -
Distance
Returns the distance between a and b.
返回a和b之间的距离。 -
ClampMagnitude
Returns a copy of vector with its magnitude clamped to maxLength.
返回向量的长度,最大不超过maxLength所指示的长度。 -
Min
Returns a vector that is made from the smallest components of two vectors.
返回一个由两个向量的最小组件组成的向量。 -
Max
Returns a vector that is made from the largest components of two vectors.
返回一个由两个向量的最大组件组成的向量。 -
operator +
Adds two vectors.
两个向量相加。 -
operator
-
Subtracts one vector from another.
一个向量减另一个向量。 -
operator
*
Multiplies a vector by a number.
由一个数乘以一个向量。 -
operator /
Divides a vector by a number.
由一个数除一个向量。也就是a/b。 -
operator ==
Returns true if the vectors are equal.
如果两个向量相等,返回真。 -
operator !=
Returns true if vectors different.
如果向量不同返回真。
声明:该文观点仅代表作者本人,牛骨文系教育信息发布平台,牛骨文仅提供信息存储空间服务。
- 上一篇: C++ 向量vector和模板的应用
- 下一篇: 三维向量的简单运算(点积、叉积及点到直线的距离)