Public Group

# Direction Vector

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

## 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 on other sites
Quote:
 Original post by Eric SnyderHello. 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 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 on other sites
Quote:
 Original post by i_luv_cplusplusA 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 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 on other sites
Thanks a lot fellas. I had suspected it had to do with unit length, and now it all makes sense! Thanks again!

1. 1
2. 2
3. 3
Rutin
16
4. 4
5. 5

• 10
• 11
• 14
• 10
• 25
• ### Forum Statistics

• Total Topics
632649
• Total Posts
3007644
• ### Who's Online (See full list)

There are no registered users currently online

×