Plane in 3d Space

I have plane from which I know a point and the normal. Both are SIMD3. I want to calculate a 2d coordinate system (directions of x and y in 3d space) , which makes scence to the User. The Planes can also be parallel to xy and so on. (But that is Easy). I also would be very thankful if there is away to get points which are on the plane to the 2D formt.

I hope you could understand my english.

Accepted Answer

You'll need to do something like

let normal = ...
let point = ...
let forward: simd_float3 = cross(normal, simd_float3(0, 0, 1))
let right: simd_float3 = cross(forward, normal)

Then you should be able to get a point on the plane by doing

let pointOnPlane = point + a * forward + b * right

where a and b are arbitrary values. Now, if normal is equal to (0, 0, 1) or (0, 0, -1), you will likely end up with null vectors of (0, 0, 0). However, in this case it is easy to generate forward and right, since the plane lies in the xy plane, so forward and right will be (+-1, 0, 0) and (0, +-1, 0). Also, the problem you are describing is very similar to generating 'camera basis vectors', so feel free to research that problem for more information and examples.

Plane in 3d Space
 
 
Q