Jump to content
  • Advertisement
Sign in to follow this  
Eric Snyder

Direction Vector

This topic is 3827 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

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
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).

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
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!