SOLVED Calculating Tangent from Normal

Hi, everyone

First, is this the appropriate place to post this, as I wasn’t too sure.

I have googled this, however a lot of the answers were either too complicated due to the Math terminologies used and/or lack of easily understood example, or I wasn’t sure how I would implement the answer myself.

So I’m asking here. So I can hopefully understand and implement what I need.

From what I understand, the tangent is perpendicular from the normal.

So here’s a square, where two corners are raised slightly.

v -1.000000 0.516746 1.000000
v 1.000000 0.000000 1.000000
v -1.000000 0.000000 -1.000000
v 1.000000 0.504169 -1.000000

vt 0.943613 0.001434
vt 0.999903 0.941847
vt 0.057807 0.941847
vt 0.000097 0.000097

vn 0.003003 0.999991 -0.003003
vn -0.237447 0.941933 0.237447
vn 0.242680 0.939262 -0.242680

f 2/1/1 4/2/2 3/3/1
f 1/4/3 2/1/1 3/3/1

So with the first triangle


// Position
v 1.000000 0.000000 1.000000
v 1.000000 0.504169 -1.000000
v -1.000000 0.000000 -1.000000
// UV
vt 0.943613 0.001434
vt 0.999903 0.941847
vt 0.057807 0.941847
// Normal
vn 0.003003 0.999991 -0.003003
vn -0.237447 0.941933 0.237447
vn 0.242680 0.939262 -0.242680

How would I calculate the tangent?

Also, when implementing normal mapping, do I need, one tangent per triangle, or one tangent per vertex.

Thanks in advance for any help.