make vectors normalized
how do I make vectors normalized?
can some one show some simple code/math?
thanks lots
If for example you have a 3-d vector (x,y,z) = V
then the length of the vector, |V| = sqrt(x^2+y^2+z^2)
and the normalized vector V is V/|V|
or
(x / sqrt(x^2+y^2+z^2), y/sqrt(x^2+y^2+z^2), z/sqrt(x^2+y^2+z^2))
this makes the length of the normalized vector 1
edit: screwed up formatting
[edited by - Cold_Steel on October 29, 2002 8:35:00 PM]
then the length of the vector, |V| = sqrt(x^2+y^2+z^2)
and the normalized vector V is V/|V|
or
(x / sqrt(x^2+y^2+z^2), y/sqrt(x^2+y^2+z^2), z/sqrt(x^2+y^2+z^2))
this makes the length of the normalized vector 1
edit: screwed up formatting
[edited by - Cold_Steel on October 29, 2002 8:35:00 PM]
______________________________"Man is born free, and everywhere he is in chains" - J.J. Rousseau
so a normalized vector has same "direction" but always has a length of 1.
is that right?
is that right?
Exactly.
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers
October 29, 2002 08:04 PM
oh yeah, know first if you really want your vector normalized, that sqrt() might slow down your code somewhat...
. Some situations you don''t need to normalize your vector you see...
.
-----------------------------
http://nomad.openglforums.com
-----------------------------


-----------------------------
http://nomad.openglforums.com
-----------------------------
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement