Vector2 二维向量
Struct
Representation of 2D vectors and points.
表示 2D 的向量和点。
This structure is used in some places to represent 2D positions and vectors (e.g. texture coordinates in a Mesh or texture offsets in Material). In the majority of other cases a Vector3 is used.
这个结构用于在一些地方表示2D的位置和向量(例如:网格中的纹理坐标或者矩阵中的纹理偏移 )。在其他情况下大多数使用Vector3。
Variables变量
- xX component of the vector.
向量的X组件。 - yY component of the vector.
向量的Y组件。 - this [int index]Access the x or y component using [0] or [1] respectively.
使用[0]或者[1]分别访问组件x或者y组件。 - normalizedReturns this vector with a magnitude of 1 (Read Only).
返回向量的长度为1(只读)。 - magnitudeReturns the length of this vector (Read Only).
返回向量的长度(只读)。 - sqrMagnitudeReturns the squared length of this vector (Read Only).
返回这个向量的长度的平方(只读)。
Constructors构造器
- Vector2Constructs a new vector with given x, y components.
创建一个新的具有给定x,y组件的向量。
Functions函数
- ScaleMultiplies every component of this vector by the same component of scale.
由缩放的相同的组件对应乘以这个矢量的每个组件。 - NormalizeMakes this vector have a magnitude of 1.
使向量的长度为1. - ToStringReturns a nicely formatted string for this vector.
返回该向量一个格式化好的字符串。
Class Variables类变量
- zeroShorthand for writing Vector2(0, 0)
写Vector2(0, 0)的简码 - oneShorthand for writing Vector2(1, 1)
写Vector2(1, 1)的简码 - upShorthand for writing Vector2(0, 1)
写Vector2(0, 1)的简码 - rightShorthand for writing Vector2(1, 0)
写Vector2(1, 0)的简码
Class Functions类函数
- LerpLinearly interpolates between two vectors.
两个向量之间的线性插值。 - MoveTowardsMoves a point current towards target.
当前的地点移向目标。 - ScaleMultiplies two vectors component-wise.
两个矢量组件对应相乘。 - DotDot Product of two vectors.
两个向量的点乘积。 - AngleReturns the angle in degrees between from and to.
在from和to之间返回一个角度。 - DistanceReturns the distance between a and b.
返回a和b之间的距离。 - ClampMagnitudeReturns a copy of vector with its magnitude clamped to maxLength.
返回向量的长度,最大不超过maxLength所指示的长度。 - MinReturns a vector that is made from the smallest components of two vectors.
返回一个由两个向量的最小组件组成的向量。 - MaxReturns 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.
如果向量不同返回真。 - operator Vector2Converts a Vector3 to a Vector2.
将一个Vector3转化成一个Vector2。 - operator Vector3Converts a Vector2 to a Vector3.
将一个Vector2转化成一个Vector3。