Archived

This topic is now archived and is closed to further replies.

BlackHwk4

normalizing

Recommended Posts

BlackHwk4    122
I''m kinda new to all this vector stuff so I read around 6 tutorials about it so far and there''s something I don''t understand. I''ve written my vector class but I think I might be doing something wrong in it. Using these three vertices: ver1.Vertex( 0.0f, 1.0f,-1.0f); ver2.Vertex(-1.0f, 0.0f, 0.0f); ver3.Vertex( 1.0f, 0.0f, 0.0f); I subtract them and do the cross product on them like this: U = ver1 - ver2; V = ver2 - ver3; normal = U ^ V; Then I get the length of normal using the Pythagoras theroem and divide normal by it''s length. So now normal equals 0, 0.707107, 0.707107. When the tutorials say that a normalized vector has a length of exactly 1, do they mean it has the length of one after you round it off or is it something I''m doing wrong? Thanks for any help.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
The lenght of your vector is given by the sum of all its squared components, so you can obtain it as:

0^2 + (0.707107)^2 + (0.707107)^2 which gives about 1.
What''s wrong?

Share this post


Link to post
Share on other sites
johnb    351
{0, 0.707107, 0.707107}

has length 1, to the limit of FP accuracy, e.g. to six decimal places. You will never get ''exactly'' one in such calculations: there always an error due to the limited number of bits in floating point calculation.

The best you can hope for is accurate to within a few parts in a million or so. This is pretty accurate: it''s a few mm per km, and is far more accurate than you can measure with normal instuments. When doing real measurements, e.g. in physics experiements, errors of parts per thousand or parts per hundred are typical.

Share this post


Link to post
Share on other sites