Three.js 如何从向量和常量得到一个平面? [英] Three.js How do you get a Plane from a vector and a constant?

查看:69
本文介绍了Three.js 如何从向量和常量得到一个平面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在three.js中,数学平面的构造函数接受2个输入:

In three.js, the constructor for the Math Plane takes 2 inputs:

normal -- (Vector3) 法向量定义指向原点的平面

normal -- (Vector3) normal vector defining the plane pointing towards the origin

constant -- (Float) 沿法向量从原点到平面的负距离

constant -- (Float) the negative distance from the origin to the plane along the normal vector

有人可以提供插图或解释这是如何工作的吗?我可以理解给定一个点和法线如何构造一个平面,或 3 个共面点,但无法弄清楚如何使用法线向量和常数.

Can someone provide an illustration or explain how this works? I can understand given a point and normal how to construct a plane, or 3 co-planar points, but can't figure out how a normal vector and constant can be used.

推荐答案

TL:DR?
数学与线性代数

TL:DR?
Mathy-ness and linear algebra

所以 3 维空间中的平面可以定义为落在 3 个点上的 2 维无限矩形(你知道的)

So planes in 3 dimensional space can be defined as a 2-dimensional infinite rectangle that falls on 3 points (what you know)

它也可以由一个垂直(法向)向量和一个平面离原点多远的常数来定义.

It can also be defined by a perpendicular (normal) vector and a constant of how far from the origin the plane is.

Three.js 取法线向量(垂直于您想要的平面的向量)并基本上应用线性代数来找到平面,然后将其移离原点恒定距离.

Three.js take the normal vector (a vector that is perpendicular to the plane you want) and basically applies linear algebra to find the plane, then moves it the constant distance away from the origin.

数学计算说明:如果我们有一个正交(垂直)的向量 A 和 B,那么它们的点积为 0.所以如果我们使用这个原理,我们实际上可以采用一个已知的向量 X 并找到 2 个将共面的正交向量 Y 和 Z(由于正交性)通过向后求解 X(点)Y = 0 和 X(点)Z = 0现在我们有 2 个共面向量来制作我们的平面,我们设置常数离原点的距离

Math Calculation Explanation: If we have a vector A and B that are orthogonal (perpendicular) then their dot product is 0. SO if we use this principle we can actually take a known Vector X and find 2 orthogonal Vectors Y and Z that will be co-planar (due to orthogonality properties) by backwards solving X (dot) Y = 0 and X (dot) Z = 0 Now we have 2 co-planar vectors to make our plane that we set the distance of the constant away from the origin

(想想向量如何有一个原点和一个端点.如果共面向量共享一个原点,那么我们有 3 个点:2 个端点和 1 个原点,也就是 3 个点来构成一个平面.)

(think how vectors have an origin and an endpoint. If the co-planar vectors share an origin, then we have 3 points: 2 ends, and 1 origin, aka 3 points to make a plane.)

数学理论解释为什么这行得通:
我画得不好(没有笔和纸来展示),但基本上,想想 3D 空间中的向量.现在考虑所有可以垂直于它的向量.基本上,这创建了无限量的垂直向量,在垂直于原点的圆中旋转,如果我们无限地跨越它们,我们就创建了一个平面.

Math Theory Explanation on why this works ahead:
I can't draw very well (without pen and paper to show), but basically, think about a vector in 3D space. Now think about all the vectors that can be perpendicular to it. Basically, that creates an infinite amount of perpendicular vectors rotated in a circle perpendicularly to the original, and if we span them infinitely, we have created a plane.

如果您有机会参加线性代数课程,我强烈推荐它.非常有趣,与计算机图形学非常相关,并且解释了很多THREEjs使用的3D空间数学

If you ever have an opportunity to take a linear algebra class, I would highly recommend it. It is extremely interesting, very related to computer graphics, and explains a lot of 3D space math that THREEjs uses

这篇关于Three.js 如何从向量和常量得到一个平面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆