向量
2016-02-20 22:36
453 查看
加法
可计算位移
U + V
减法
求得两个向量的方向
U-V = VU
点乘
Unity中用于计算角度
一般来说,点乘结果描述了两个向量的“相似”程度,点乘结果越大,两个向量越相近,
点乘和向量间的夹角相关
计算两向量间的夹角 θ = arccos(a·b)
叉乘
叉乘得到的向量垂直于原来的两个向量。
a × b 的长度等于向量的大小与向量夹角sin值的积,||a × b|| = ||a|| ||b|| sinθ
叉乘最重要的应用就是创建垂直于平面、三角形、多边形的向量。
可计算位移
U + V
减法
求得两个向量的方向
U-V = VU
using UnityEngine; using System.Collections; public class Test : MonoBehaviour { private Vector3 target = new Vector3(100,0,100); private Vector3 normal; // Use this for initialization void Start () { //U - V = VU normal = (target - transform.position).normalized; } // Update is called once per frame void Update () { if (Vector3.Distance(target,transform.position) > 0.1) { transform.position += 0.1f * normal; } else { transform.position = target; } } }
点乘
Unity中用于计算角度
一般来说,点乘结果描述了两个向量的“相似”程度,点乘结果越大,两个向量越相近,
点乘和向量间的夹角相关
计算两向量间的夹角 θ = arccos(a·b)
叉乘
叉乘得到的向量垂直于原来的两个向量。
a × b 的长度等于向量的大小与向量夹角sin值的积,||a × b|| = ||a|| ||b|| sinθ
叉乘最重要的应用就是创建垂直于平面、三角形、多边形的向量。
相关文章推荐
- jQuery单页应用无刷新插件
- Nginx的源码安装
- VS2015--win32工程配置的一些想法之warning LNK4042: 对象被多次指定;已忽略多余的指定
- Experimental Educational Round: VolBIT Formulas Blitz(J)打表找规律
- vs2015 + BabeLua + Cocos2d-x 3.10配置
- VS2015--win32工程配置的一些想法之warning LNK4042: 对象被多次指定;已忽略多余的指定
- String to Integer (atoi) - 字符串转为整形,atoi 函数(Java )
- CodeForces 625B 字符串模拟+思维
- 【前端学习】sublime开启vim模式
- 1007. Maximum Subsequence Sum (25)
- Android监听应用程序安装和卸载
- hdu 3001 Travelling 状压dp
- 《红与黑》摘抄及读后感
- 1006. Sign In and Sign Out (25)
- shell 根据输入的IP,找到对应的hostname
- Edu CF #R8(ABC)
- Mina的大量连接问题
- Experimental Educational Round: VolBIT Formulas Blitz(F)排列组合
- Agent admitted failure to sign using the key
- OpenJudge百炼习题解答(C++ )--题4112:情报破译-Cryptanalysis