Three.js How do you get a Plane from a vector and a constant?

安稳与你 提交于 2019-12-22 00:22:18

问题


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

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

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

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.


回答1:


TL:DR?
Mathy-ness and linear algebra

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 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.

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

(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.)

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.

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



来源:https://stackoverflow.com/questions/38665067/three-js-how-do-you-get-a-plane-from-a-vector-and-a-constant

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!