Direction Vector

Started by
4 comments, last by Eric Snyder 16 years, 3 months ago
Hello. I just joined the forum and am looking forward to participating. I am old to programming but new to 3D graphics applications. I started reading a book on the subject and I have a question. My book states, "Using the standard convention, a direction vector must have unit length. For example, (1,0,0) is a direction vector, but (1,1,1) is not since its length is the square root of three." It seems obvious to me that (1,1,1) has length, so I am guessing that 'unit length' is the operative word here. Does anyone know what unit length is? Thanks!
Advertisement
Quote:Original post by Eric Snyder
Hello. I just joined the forum and am looking forward to participating. I am old to programming but new to 3D graphics applications. I started reading a book on the subject and I have a question.

My book states, "Using the standard convention, a direction vector must have unit length. For example, (1,0,0) is a direction vector, but (1,1,1) is not since its length is the square root of three."

It seems obvious to me that (1,1,1) has length, so I am guessing that 'unit length' is the operative word here. Does anyone know what unit length is?

Thanks!
'Unit length' simply means a length of one.

Working with vectors of unit length is often simpler and cheaper than working with vectors of arbitrary length. Many vector equations include the lengths or squared lengths as terms, and when the vectors in question are unit-length, these terms usually drop out, simplifying the equation (this often eliminates expensive square roots as well).
A vector has unit length if for (x,y,z) x+y+z = 1

vector of unit length stores only the direction. It's useful when calculating many directions and you don't want lengths of vectors to influence the final result.

to convert any vector to unit length vector, you must divide x,y,z by length of vector. this process is called normalizing.

pseudocode:

length = sqrt(x*x+y*y+z*z)
x = x/length;
y = y/length;
z = z/length;
OpenGL fanboy.
Quote:Original post by i_luv_cplusplus
A vector has unit length if for (x,y,z) x+y+z = 1


This is wrong.

If read as "x + y + z = 1 implies |(x, y, z)| = 1", you're wrong because...
u = (1/3, 1/3, 1/3)
|u| = sqrt(1/3)

If read as "A vector (x, y, z) has unit length if and only if x + y + z = 1", you're wrong because...
v = (0.5, 0.25, sqrt(0.6875))
|v| = 1
[TheUnbeliever]
ah i said it wrong

it was supposed to be like it:

length of unit vector = 1
length = sqrt(x^2 + y^2 + z^2)
for sqrt(x^2 + y^2 + z^2) to be equal to 1, x^2+y^2+z^2 must be equal 1
OpenGL fanboy.
Thanks a lot fellas. I had suspected it had to do with unit length, and now it all makes sense! Thanks again!

This topic is closed to new replies.

Advertisement