Vector help...

Blitz3D Forums/Blitz3D Programming/Vector help...

aCiD2(Posted 2004) [#1]
Im trying to understand tangent space and therefore apply it in Blitz... I'm not very good with vectors though, can someone explain some of this..?



I don't understand how to normalize a vecotr (alothugh i heard its meant to result in the length being 1?) and what does it mean 'X is the cross product.' The cross product of what? Just the vertex? :) If anyone can go through that code, i'd really appriate it xD


ZombieWoof(Posted 2004) [#2]
normalize:
dc = 1/sqr(x*x+y*y+z*z) ; compute correction factor
x=x*dc
y=y*dc
z=z*dc

cross product:
http://mathworld.wolfram.com/CrossProduct.html

A cross product is the vector normal to the plane defined by 2 other vectors

Beyond that, I'm as confused, if not more so, than you are :)


aCiD2(Posted 2004) [#3]
Thanks for those snips Zombie :) Now that i've got some of these formula's "in the bag" (i love that phrase ^_^) I may will be able to get some nice Dot3 Lighting down.


aCiD2(Posted 2004) [#4]
Some more questions:
In the following, it seems that a vector also has 'U' and 'V' parts? I don't think that these are talking about texture co-ordinates either.

The tangent space is made of three vectors: the tangent, the binormal and the normal. The tangent is the vector along which the U coordinates of the vertices are increased. The binormal is the vector along which the V coordinates of the vertices are increased. The normal is... the normal!
Most of the time the three vectors are orthogonal. In some cases they are not, but lighting will still work.

And here we see another mention of a vector having 'u' and 'v' components...
(p2->x-p1->x,p2->u-p1->u,p2->v-p1->v)

Any ideas?


ZombieWoof(Posted 2004) [#5]
thats where you start losing me -- on those math sites, u/v are polar vectors, not texture coords :) that is if I'm reading any part of it right :)

I dropped the idea of a math major and went with a puter major instead :) I'm definitly a lazy git :)


Warren(Posted 2004) [#6]
dc = 1/sqr(x*x+y*y+z*z)

Watch out for divide by zero here.


aCiD2(Posted 2004) [#7]
Im using Noel Cowers vector maths lib, and i think that it checks


poopla(Posted 2004) [#8]
Ya think this stuff is tough, take a look a matrix manipulations(in fact, do it anyway, they're very useful.)