Search code examples
vectorgeometryvertex

How to find the vertexes of a flat wall given it's center pos, it's normal, it's width and it's length?


I'm defining a flat wall as a center pos (cx,cy,cz), a normal (nx,ny,nz), a vector pointing to the up-direction of the wall (ux,uy,uz) it's width and length (w,l). How do I find the position of it's 4 vertexes?


Solution

  • I'll assume that by length, you mean height. First, make sure that your up and normal vectors are normalized. You can multiply the up vector by the length, and add and subtract the result from the center to get the temporary results A and B, respectively.

    Then, cross product the up vector with the normal vector to get the right vector (or left, depending on what order you do the cross product). Then multiply the right vector by the width, and add and subtract this from the center to get two more temporary results, C and D, respectively.

    Finally, the four corners of the quad can be obtained by adding each of C and D to each of A and B.