返回介绍

Vector2 二维向量

发布于 2019-12-18 15:38:42 字数 7149 浏览 1082 评论 0 收藏 0

Description 描述

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。

Static Variables 静态变量

oneShorthand for writing Vector2(1, 1).
Vector2(1, 1)的简写。
rightShorthand for writing Vector2(1, 0).
Vector2(1, 0)的简写。
upShorthand for writing Vector2(0, 1).
Vector2(0, 1)的简写。
zeroShorthand for writing Vector2(0, 0).
Vector2(0, 0)的简写。

Variables 变量

magnitudeReturns the length of this vector (Read Only).
返回向量的长度(只读)。
normalizedReturns this vector with a magnitude of 1 (Read Only).
返回向量的长度为1(只读)。
sqrMagnitudeReturns the squared length of this vector (Read Only).
返回这个向量的长度的平方(只读)。
this[int]Access the x or y component using [0] or [1] respectively.
使用(索引器)[0]或者[1]分别访问组件x或者y组件。
xX component of the vector.
向量的X组件。
yY component of the vector.
向量的Y组件。

Constructors 构造器

Vector2Constructs a new vector with given x, y components.
创建一个新的具有给定x,y组件的向量。

Functions 函数

NormalizeMakes this vector have a magnitude of 1.
使向量的长度为1。
SetSet x and y components of an existing Vector2.
设置已知二维变量的x和y。
ToStringReturns a nicely formatted string for this vector.
返回该向量一个格式化好的字符串。

Static Functions 静态函数

AngleReturns the angle in degrees between from and to.
在from和to之间返回一个角度。
ClampMagnitudeReturns a copy of vector with its magnitude clamped to maxLength.
返回向量的长度,最大不超过maxLength所指示的长度。
DistanceReturns the distance between a and b.
返回a和b之间的距离。
DotDot Product of two vectors.
两个向量的点乘积。
LerpLinearly interpolates between two vectors.
两个向量之间的线性插值。
MaxReturns a vector that is made from the largest components of two vectors.
返回一个由两个向量的最大组件组成的向量。
MinReturns a vector that is made from the smallest components of two vectors.
返回一个由两个向量的最小组件组成的向量。
MoveTowardsMoves a point current towards target.
当前的地点移向目标。
ReflectReflects a vector off the vector defined by a normal.
定义在正常情况下映射向量离开向量。
ScaleMultiplies two vectors component-wise.
两个矢量组件对应相乘。
SmoothDampGradually changes a vector towards a desired goal over time.
随着时间的推移逐渐改变一个向量朝着期望的目标。

Operators 运算符

operator -Subtracts one vector from another.
一个向量减去另一个向量。
operator !=Returns true if vectors different.
如果向量不同返回真。
operator *Multiplies a vector by a number.
一个向量乘以一个数字。
operator /Divides a vector by a number.
一个向量除以一个数字。
operator +Adds two vectors.
两个向量相加。
operator ==Returns true if the vectors are equal.
如果向量相等返回真。
operator Vector2Converts a Vector3 to a Vector2.
将一个Vector3转化成一个Vector2。
operator Vector3Converts a Vector2 to a Vector3.
将一个Vector2转化成一个Vector3。

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文