关于 Vector3.normalize(); 的问题
读完谷歌后,我仍然不太明白这是什么意思?有人可以解释一下吗?可能是一个简单的例子?非常感谢。
After reading google, I still don't quite understand what this does/means? Could someone explain this? Possibly a simple example? Thank you very much.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
标准化向量意味着改变其分量,使其总长度等于 1。
用伪代码表示:
这在实时 3D 中有很多用途,因为标准化向量具有有趣的属性。
Normalizing a vector means changing its components so its total length is equal to 1.
In pseudo-code:
This has many uses in real-time 3D, as normed vectors have interesting properties.
标准化向量会将其长度缩放为 1.0,而不改变其方向。
编辑:这是通过查找向量的长度然后将每个坐标除以长度来实现的:
length = sqrt(x*x + y*y + z*z);
范数 = [ x / 长度, y / 长度, z / 长度];
显然,您无法标准化零长度向量。
Normalizing a vector scales it to length 1.0, without changing its direction.
Edit: This works by finding the length of the vector and then dividing each of the co-ordinates by the length:
length = sqrt(x*x + y*y + z*z);
norm = [ x / length, y / length, z / length];
Clearly you cannot normalize a zero-length vector.