View Full Version : vector "type"?

technologist

11-05-2017, 04:41 PM

Broadly speaking I am trying to better understand the cartesian type of coordinate systems. In many tutorials "vectors" transformed by rotation and movement matrices just to name a few don't have magnitude and direction information.

Ques: are "vectors" in glut/openGL position vectors, as opposed to more traditional understanding in which it has magnitude and direction.

Alfonse Reinheart

11-05-2017, 06:31 PM

In many tutorials "vectors" transformed by rotation and movement matrices just to name a few don't have magnitude and direction information.

Nonsense. All vectors have magnitude and direction. If you want to see the direction of any vector, normalize it. If you want to see the magnitude of a vector, get its length. Only the origin vector (0, 0, 0) has a zero magnitude and no direction.

What you're confusing is how you interpret the meaning of a vector. That is, what a vector represents.

Consider 10. What is that? It's just a number. It doesn't have meaning beyond that. I can choose to interpret this as the number of eggs I have. That gives it a meaning.

The vector (2, 5) also is just a pair of numbers. It doesn't have meaning beyond that.

By interpreting this vector as a direction in some space, you give it meaning. By interpreting it as a position in some space, you give it meaning. These are two different meanings. But that's no different from 10 eggs being different from 10 inches, which is different from 10 grams. They're all 10s, but they mean different things.

A vector is merely a mathematical concept. It is the application of it which gives it a meaning. A vector, in terms of spaces, can represent a direction in a space or a position in a space. But that doesn't change what math you can do on it.

For example, I can add 10 and 10 to get 20. For the process of addition, the meaning behind those numbers is irrelevant. But that doesn't mean it makes any kind of sense to add 10 eggs to 10 inches. That may be a mathematically valid thing you can do, but the result has no real meaning.

And the same goes with vectors.

Vector math works for any vectors. You can add two vectors, you can subtract a vector from another, you can multiply two vectors together, etc.

But those only have meaning with certain interpretations of a vector. Adding two positions doesn't really make sense, while adding two directions does make sense. Multiplying a position with a direction makes sense (scaling the position in the given direction by its magnitude), but multiplying two positions does not. And so forth.

The math can work even if the meaning behind it breaks down. Your job is to separate the math from the meaning. Always remember which vectors represent positions and directions. Sometimes, you can logically change between the two, depending on what you're doing. But don't allow the possibilities that the math offers to blind you to the meaning of what's going on.

technologist

11-06-2017, 07:23 AM

Thx for the reply. ..Is whether that vector is a position or direction by indicating this in the vector:

[1,2,3,0] - 0->direction vector

[1,2,3,1] - 1->position vector

So I wouldn't use glTranslate to move a direction.

All vectors have magnitude and direction.

I would restate this as all vectors have magnitude and direction that sometimes have be derived from the numbers. Thus, finding the meaning in greater context as you suggested such as the Cartesian components of the vectors in question.

GClements

11-06-2017, 10:39 AM

Is whether that vector is a position or direction by indicating this in the vector:

[1,2,3,0] - 0->direction vector

[1,2,3,1] - 1->position vector

So I wouldn't use glTranslate to move a direction.

Translating a homogeneous vector with a zero W component won't have any effect:

[ 1 0 0 tx ] [ x ] [ x ]

[ 0 1 0 ty ] * [ y ] = [ y ]

[ 0 0 1 tz ] [ z ] [ z ]

[ 0 0 0 1 ] [ 0 ] [ 0 ]

If you consider vectors with W=0 as directions and vectors with W=1 as positions, then addition two directions gives a direction while adding a position and a direction gives a position (adding two positions gives their midpoint; the resulting vector has W=2).

technologist

11-06-2017, 11:44 AM

Translating a homogeneous vector with a zero W component won't have any effect:

[ 1 0 0 tx ] [ x ] [ x ]

[ 0 1 0 ty ] * [ y ] = [ y ]

[ 0 0 1 tz ] [ z ] [ z ]

[ 0 0 0 1 ] [ 0 ] [ 0 ]

If you consider vectors with W=0 as directions and vectors with W=1 as positions, then addition two directions gives a direction while adding a position and a direction gives a position (adding two positions gives their midpoint; the resulting vector has W=2).

Ok (sorry to be so dense here) so if W=0 then what is the direction for that vector if as it seems you have x,y,z,W. Do you just 'unpack' that information by breaking down the vector to components and angles? I can solve for the length of vector from origin , etc.

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.