Sign in to follow this  
Eric Snyder

Direction Vector

Recommended Posts

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!

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
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;

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this