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

Normalizing Vectors...

This topic is 6077 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Guest Anonymous Poster
Here''s a small optimization you could use:

void normalize(VECTOR * v)
float c = 1.0f / sqrt(v.x * v.x +v.y * v.y +v.z * v.z);
v.x *= c;
v.y *= c;
v.z *= c;

A multiplication is around 12 times faster than a division, so you''ve only to divide one time.

It''s really a VERY SMALL amount of time you''ll save, but why not cause it''s only a minimal change.

Share this post

Link to post
Share on other sites