#### Archived

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

# normalizing

## Recommended Posts

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 on other sites
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 on other sites
{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.

• ### Forum Statistics

• Total Topics
628394
• Total Posts
2982431

• 10
• 9
• 19
• 24
• 9