Unity3D圣典3.3版本-中文版
文集大纲加载中……
本文档使用 MrDoc 发布
-
+
首页
Vector3.Dot 点乘
# [Vector3](Vector3.html).Dot 点乘 static function *Dot* (*lhs* : [Vector3](Vector3.html), *rhs* : [Vector3](Vector3.html)) : float *Description* 描述 Dot Product of two vectors. 两个向量的点乘积。 Returns lhs . rhs. 返回 lhs . rhs。 For [normalized](Vector3.normalized.html) vectors Dot returns 1 if they point in exactly the same direction; -1 if they point in completely opposite directions; and a number in between for other cases (e.g. Dot returns zero if vectors are perpendicular). 对于 [normalized](Vector3.normalized.html) 向量,如果他们指向在完全相同的方向,Dot 返回 1。如果他们指向完全相反的方向,返回-1。对于其他的情况返回一个数(例如:如果是垂直的 Dot 返回 0)。 For vectors of arbitrary length the Dot return values are similar: they get larger when the angle between vectors decreases. 对于任意长度的向量,Dot 返回值是相同的:当向量之间的角度减小,它们得到更大的值。 * [C#](#) * [JavaScript](#) ``` using UnityEngine; using System.Collections; public class example : MonoBehaviour { public Transform other; void Update() { if (typeof(other)) { Vector3 forward = transform.TransformDirection(Vector3.forward); Vector3 toOther = other.position - transform.position; if (Vector3.Dot(forward, toOther) < 0) print("The other transform is behind me!"); } } } ``` ``` // detects if other transform is behind this object //检测其他变换是否在这个物体的后面 var other : Transform; function Update() { if (other) { var forward = transform.TransformDirection(Vector3.forward); var toOther = other.position - transform.position; if (Vector3.Dot(forward,toOther) < 0) print ("The other transform is behind me!"); } } ```
da
2022年5月23日 21:48
转发文档
收藏文档
上一篇
下一篇
手机扫码
复制链接
手机扫一扫转发分享
复制链接
关于 MrDoc
觅思文档MrDoc
是
州的先生
开发并开源的在线文档系统,其适合作为个人和小型团队的云笔记、文档和知识库管理工具。
如果觅思文档给你或你的团队带来了帮助,欢迎对作者进行一些打赏捐助,这将有力支持作者持续投入精力更新和维护觅思文档,感谢你的捐助!
>>>捐助鸣谢列表
微信
支付宝
QQ
PayPal
Markdown文件
分享
链接
类型
密码
更新密码