2d points back to 3d

Here’s the problem. I first had my 3d points and I needed to find the intersection polygon between a square polygon and a triangle polygon. So the easiest way to do that is using 2d points instead of 3d, since the triangle and square were on the same plane. So I used the tangent vector and binormal and did this:

out.x = Dot(tangent, point);
out.y = Dot(binormal, point);

that worked well. But now that I have my new 2d points how could I convert them back to 3d if I have the tangent, binormal and normal information? Thanks.

The operation you performed by selecting a binormal and tangent followed by a dot product of the vertices with these vectors is basically a rotation.

This rotation mapped the normal to the Z-axis (if your 2d points are in the XY plane)

| Bx By Bz | | Nx|   | 0 |
| Tx Ty Tz |.| Ny| = | 0 |
| Nx Ny Nz | | Nz|   | 1 |

So what you want to do, is apply the inverse transform. Luckely, the invers of a rotationmatrix is equal to its transpose.
So you have to apply the following matrix:

| Bx Tx Nx |
| By Ty Ny |
| Bz Tz Nz |

Depending on how you’ve written your code, the tangent and binormal should be interchanged.

N.