Vector3 学习与应用
来源:互联网 发布:淘宝网京东商城电器 编辑:程序博客网 时间:2024/05/17 00:14
Description
Multiplies every component of this vector by the same component of
所有的轴向都乘以scale
static function Scale (a : Vector3, b : Vector3) : Vector3
Description
Multiplies two vectors component-wise.
Every component in the result is a component of
Description
Makes this vector have a
让向量的长度变成1
When normalized, a vector keeps the same direction but its length is 1.0.
当normalized, 向量的方向不会变但是长度会变成1,0
Note that this function will change the current vector. If you want to keep the current vector unchanged, use
这个函数会改变使用这个函数的向量,如果你不想改变这个向量,应该使用normalized
If this vector is too small to be normalized it will be set to zero
如果这个向量太小了,他不适合normalized并会被设置成zero (0,0,0)
Description
Returns a nicely formatted string for this vector
返回x,y,z的值,一般到小数点后一位。(0.0, 0.0, 0.0)
Class Variables
zero=(0,0,0)
one=(1,1,1)
forward=(0,0,1)
up=(0,1,0)
right=(1,0,0)
还有一个文档没写但也可以用的 left=(-1,0,0)
Class Functions
1)static
Description
Linearly interpolates between two vectors.
Interpolates
t
跟Quaternion里的lerp一样,返回from 和to之间的一个Vector3 点p
2)static
Description
Spherically interpolates between two vectors.
Interpolates
t
作用跟lerp差不多,但是不是呈直线靠近。
3)static
Description
Makes vectors normalized and orthogonal to each other.
Normalizes
See Also:
这个函数读入两个向量normal和tangent, 使tangent 在由tangent 和normal构成的平面上,并与normal垂直。两个向量都被Normalize,也就是长度为1。大家可以用这个脚本在编辑器中看出这个函数是如何工作的。
static function OrthoNormalize (ref normal : Vector3, ref tangent : Vector3, ref binormal : Vector3) : void
Description
Makes vectors normalized and orthogonal to each other.
Normalizes
See Also:
Description
Rotates a vector/from/ towards
The vector will be rotated on an arc instead of being interpolated linearly. This is essentially the same as
产生一个向量从from旋转并移动到 to,跟Vector3.Slerp类似,但是可以用maxRadiansDelta和max MagnitudeDelta分别控制向量的旋转方向和长度。当maxRadiansDelta=0时,向量指向from, 1则指向to。 当maxMagnitudeDelta=0时,向量的长度=from.magnitude,1则=to.magnitude。 向量的最大有效取值范围为1, 但是最小取值范围可以小于0
maxMagnitudeDelta, maxRadiansDelta [0,-∞]
当maxRadiansDelta和maxMagnitudeDelta为负时,向量会向相反方向旋转和延长。
5)function
Description
Multiplies every component of this vector by the same component of
将两个向量的对应轴相乘。
a,b ∈Vector3
a.Scale(b);
a.x=a.x * b.x
static function Scale (a : Vector3, b : Vector3) : Vector3
Description
Multiplies two vectors component-wise.
Every component in the result is a component of
跟上一个差不多
a,b,c ∈Vector3
a.x=b.x * c.x
6)static
Description
Cross Product of two vectors.
Returns
两个向量的叉积,具体关于叉积的解释大家可以自己去网上搜搜,或点击传送门。
http://zh.wikipedia.org/zh/向量积
http://baike.baidu.com/view/865221.htm
- a
= a1i + a2j + a3k = [a1, a2, a3]
- b
= b1i + b2j + b3k = [b1, b2, b3]
则
- a
× b = [a2b3 − a3b2, a3b1 − a1b3, a1b2 − a2b1]
7)static
Description
Reflects the vector along the normal.
The returned value is
又一个很常用的函数,返回一个向量,让这个向量与另一个向量inDirection以坐标轴inNormal为准镜像。
Description
Dot Product of two vectors.
Returns
For
For vectors of arbitrary length the Dot return values are similar: they get larger when the angle between vectors decreases.
点积,跟quaternion里的用法一样。对于normalized后的lhs和rhs,如果指向相同的方向,返回1。返回-1如果他们指向完全相反的方向。其他情况下根据角度返回两者之间的小数。如果两个向量互相垂直,返回0;
点
9)static
Description
Projects a vector onto another vector.
Returns
投射一个向量到另一个。
返回一个向量,这个向量由vector投射到onNormal。 返回0如果onNormal几乎等于或等于0;
具体工作原理可以通过这个脚本了解到
10)static
Description
Returns the angle in degrees between
这个基本上是我用的非常多的一个函数,用来确定两个向量指向的位置间的夹角
返回从from到to的夹角,单位为度。
我一般用这个来测量坦克之类的车辆的y轴和空间坐标y轴之间的夹角,阻止其登上大于固定角度的斜坡。或者ai只会看见正前方多少度内的敌人,因为他不应该拥有360度的视野。
11)static
Description
Returns the distance between
Vector3.Distance(a,b)
返回从a到b的距离
使用这个函数Vector3.Distance(a,b)的结果跟直接在两个向量间作减法(a-b)后求出的向量的长度是一样的。
也是非常非常常用到的一个函数。
12)static
Description
Returns a vector that is made from the smallest components of
返回lhs和rhs中最小的那个向量
13)static
Description
Returns a vector that is made from the largest components of
返回lhs和rhs中最大的那个向量
这两个也是很常用的。
14)operators
+ 和-
两个向量相加和相减
*和/
一个向量的所有轴乘以或除以一个float或int, 得到一个新的向量
==和!=
不知道的该打屁股
- Vector3 学习与应用
- Unity3d之Vector3 学习与应用
- [unity基础知识]之Unity3d之Vector3 学习与应用
- Vector3.Dot 与Vector3.Cross
- Vector3.Dot 与Vector3.Cross
- Unity ScriptingAPI Vector3学习
- Vector3
- Vector3
- Vector3
- Vector3
- Vector3
- Unity3D Vector3.Dot 点乘 与 Vector3.Cross 叉乘
- Unity3D Vector3.Dot 点乘 与 Vector3.Cross 叉乘
- Unity3D Vector3.Dot 点乘 与 Vector3.Cross 叉乘
- Unity3D Vector3.Dot 点乘 与 Vector3.Cross 叉乘
- Unity3D Vector3.Dot 点乘 与 Vector3.Cross 叉乘
- 蓝鸥Unity入门Vector3学习笔记
- Vector3.normalized Vector3.normalize()
- Windows使用ssh远程登录Linux
- cocos2dx读取tiledmap地图常见问题
- python 合并dict
- 《谁的青春不迷茫》阅读笔记
- 用SQL将查询出来的多列的值拼接成一个字符串
- Vector3 学习与应用
- Unity 管理www类访问的写法
- BZOJ 1093 [ZJOI 2007] 最大半连通子图 (tarjan+树形DP)
- HDU 4436 str2int 后缀数组(前缀和预处理)
- iphone 适配LaunchImage
- C代码优化方案
- 用StreamReader读取中文出现乱码的解决方案
- (转)http请求和http响应详细解析
- uva714Copying Books