3
$\begingroup$

As I understand it: In graphics, 3D vectors are usually represented as homogeneous coordinates by storing an additional $w$ component known as the weight. The vector is divided by $w$ to obtain the corresponding Cartesian coordinates.

My confusion is rooted in my inexperience with the topic, so I have a few questions:

  • Vectors representing points have $w = 1$. During operations such as addition, scalar multiplication, and cross product, does $w$ ever (need to) change? I know it can in matrix-vector multiplication (for example, when applying perspective projection).
  • When would we need to initialize a vector with $w$ as any other value? I've heard that directions can be represented by $w=0$ (a point at infinity in the direction of the vector) but I am not quite clear on this.

Thank you in advance!

$\endgroup$

1 Answer 1

3
$\begingroup$

If, like me, you did vectors in high school or even Uni, they often had to 'qualify' whether you had a '(direction) vector' or a 'position vector'. I know my kids found it confusing.

One way to think about it is that adding the extra coordinate, w, fixes/unifies this. When w=0 it implies it's a direction vector, while w=1, a position vector.

For example, if you take the difference of two position vectors (ie both w=1) you automatically get a direction vector (w=0). If you take the average of two position vectors $\frac{A+B}{2}$, you will automatically again get a position vector - (in fact, just adding two position vectors is sort of effectively computing the average since $(wX, wY, wZ, w)$ maps back to $(X, Y, Z)$)

As for your questions above, with multiplication, if you scale a 'direction vector' it's the same as you'd expect. Scaling a purely position vector it's more like the first part of a weighted sum. A cross product probably only makes sense (to me at least) for direction vectors - not given it much thought otherwise.

For other values of w - perhaps you should look at rational Bezier splines. These have control points with "w" components and you interpolate the w values much the same as the x, y & zs.... but map back to xyz by the division by w. With rational quadratic Beziers, for example, you can do sections of conics, eg circles.

As a follow-up question, how would one "add vectors" in the traditional sense with homogeneous coordinates? That is, if adding two position vectors gives the average, how do we obtain the vector sum representing the translation of a point to another point (e.g. (a,b,c)+(x,y,z)=(a+x,b+y,c+z))? Adding a position vector to a direction vector does the trick (we end up with w=1), but I don't see how that geometrically makes sense

A translation is done by a 'direction' vector, i.e has w=0. I was thinking maybe a way of viewing it is to consider the origin as the position vector $O_p=(0,0,0,1)$. Given some direction vectors e.g.$A_d=(A_x,A_y,A_z,0)$ and $B_d=(B_x,...,0)$, then a new position can be given by combinations $Another_p = O_p + A_d + B_d - C_d + 7 * D_d + etc$

$\endgroup$
3
  • $\begingroup$ Thank you! As a follow-up question, how would one "add vectors" in the traditional sense with homogeneous coordinates? That is, if adding two position vectors gives the average, how do we obtain the vector sum representing the translation of a point to another point (e.g. $(a,b,c)+(x,y,z)=(a+x,b+y,c+z)$)? Adding a position vector to a direction vector does the trick (we end up with $w=1$), but I don't see how that geometrically makes sense. $\endgroup$
    – Scene
    Commented Jun 1 at 6:39
  • 1
    $\begingroup$ I'll add that to the answer above $\endgroup$
    – Simon F
    Commented Jun 2 at 15:40
  • 1
    $\begingroup$ I appreciate your help! That does make sense. $\endgroup$
    – Scene
    Commented Jun 2 at 16:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.