<p>Various operations on 2D vectors naturally generalise to 3D vectors simply by including the <span class="math-container">$z$</span>-coordinate. The ones that come to mind are:</p>

<ul>
<li>Vector sum and difference</li>
<li>Dot product</li>
<li>Magnitude (Euclidean norm)</li>
</ul>

<p>Various graphics programming tasks also use 4D vectors, usually(?) to represent points in 3D projective space (AKA homogeneous coordinates). Given this, it would seem that the above operations should <em>not</em> use the <span class="math-container">$w$</span>-coordinate.</p>

<p>For example, the magnitude of a 4D vector would be calculated in exactly the same way as the equivalent 3D vector:</p>

<p><span class="math-container">$\lVert \mathbf{v} \rVert = \sqrt{x^2+y^2+z^2}$</span></p>

<p>...and not with the inclusion of the <span class="math-container">$w$</span>-coordinate:</p>

<p><span class="math-container">$\lVert \mathbf{v} \rVert = \sqrt{x^2+y^2+z^2+w^2}$</span></p>

<p>(For a point at infinity, where <span class="math-container">$w=0$</span>, there wouldn't be a difference, but for finite points, there would. I'm also assuming that a finite 4D homogeneous vector is in canonical form, with <span class="math-container">$w=1$</span>.)</p>

<p><strong>Is this always the case?</strong> Is there any situation in graphics programming where calculations on 4D vectors should <em>not</em> treat them as their 3D equivalents, but should actually make use of the <span class="math-container">$w$</span>-coordinate?</p>

CC BY-SA 4.0
2019-12-23T15:40:16.123Z
Projective, homogeneous; homogeneous, projective. I'll include both names in the question.
Tim Pederick
CC BY-SA 4.0
2019-12-23T15:45:12.897Z
I'm confused by your vector magnitude example. If you are using homogenous coordinates then  surely all vectors of the form ${W.V_x, W.V_y, W.V_z, W}$ are "equivalent" and so wouldn't the magnitude thus be $\frac{\sqrt{V_x^2+V_y^2+V_z^2} }{W}$
Simon F
CC BY-SA 4.0
2019-12-23T16:04:13.313Z
@SimonF: That's why I specified that I'm assuming vectors are in canonical form, with $w=1$.
Tim Pederick
CC BY-SA 4.0
2019-12-23T16:11:25.933Z
Oops. Sorry, missed that!  FWIW you do get use cases, however, where $w\neq1$ in graphics e.g. extruding shadow volumes to infinity or doing rational  splines.
Simon F
CC BY-SA 4.0
2019-12-23T19:42:57.117Z
Yes, when your 4D vector is not just a projective extension of your 3D one. Some examples off the top of my head: spatio-temporal vector, 4d rendering, quadric surfaces, quaternions.
lightxbulb
CC BY-SA 4.0
2019-12-24T02:24:24.127Z
@lightxbulb: My understanding was that quaternions are treated separately, as they come with their own set of operations; but maybe those operations are identical in calculation (if not in concept) to the vector operations? As for 4D rendering, I am not familiar with this and would like to know more...
Tim Pederick
CC BY-SA 4.0
2019-12-24T10:43:06.873Z
You can write quaternions as 4D vectors as long as you  define the operations correctly. Then the magnitude is your usual 4d vector magnitude (for rotation quaternions it is always 1). 4D rendering is just what it implies - rendering a 4D scene. This is usually achieved by projecting the 4D world to a 3D volume and then projecting that to a 2D plane.
lightxbulb
<mathematics><vectors>
When should operations on 4D (homogeneous/projective) vectors use the w-coordinate?
Tim Pederick
# When should operations on 4D (homogeneous/projective) vectors use the w-coordinate?

(Asked by: username_0 on 2019-12-23)

Various operations on 2D vectors naturally generalise to 3D vectors simply by including the $z$-coordinate. The ones that come to mind are:

* Vector sum and difference
* Dot product
* Magnitude (Euclidean norm)

Various graphics programming tasks also use 4D vectors, usually(?) to represent points in 3D projective space (AKA homogeneous coordinates). Given this, it would seem that the above operations should *not* use the $w$-coordinate.

For example, the magnitude of a 4D vector would be calculated in exactly the same way as the equivalent 3D vector:

$\lVert \mathbf{v} \rVert = \sqrt{x^2+y^2+z^2}$

...and not with the inclusion of the $w$-coordinate:

$\lVert \mathbf{v} \rVert = \sqrt{x^2+y^2+z^2+w^2}$

(For a point at infinity, where $w=0$, there wouldn't be a difference, but for finite points, there would. I'm also assuming that a finite 4D homogeneous vector is in canonical form, with $w=1$.)

**Is this always the case?** Is there any situation in graphics programming where calculations on 4D vectors should *not* treat them as their 3D equivalents, but should actually make use of the $w$-coordinate?

**Tags:** mathematics, vectors

> **Comments:**
> **username_0**: Projective, homogeneous; homogeneous, projective. I'll include both names in the question.  
> **username_1**: I'm confused by your vector magnitude example. If you are using homogenous coordinates then  surely all vectors of the form ${W.V_x, W.V_y, W.V_z, W}$ are "equivalent" and so wouldn't the magnitude thus be $\frac{\sqrt{V_x^2+V_y^2+V_z^2} }{W}$  
> **username_0**: @username_1: That's why I specified that I'm assuming vectors are in canonical form, with $w=1$.  
> **username_1**: Oops. Sorry, missed that!  FWIW you do get use cases, however, where $w\neq1$ in graphics e.g. extruding shadow volumes to infinity or doing rational  splines.  
> **username_2**: Yes, when your 4D vector is not just a projective extension of your 3D one. Some examples off the top of my head: spatio-temporal vector, 4d rendering, quadric surfaces, quaternions.  
> **username_0**: @username_2: My understanding was that quaternions are treated separately, as they come with their own set of operations; but maybe those operations are identical in calculation (if not in concept) to the vector operations? As for 4D rendering, I am not familiar with this and would like to know more...  
> **username_2**: You can write quaternions as 4D vectors as long as you  define the operations correctly. Then the magnitude is your usual 4d vector magnitude (for rotation quaternions it is always 1). 4D rendering is just what it implies - rendering a 4D scene. This is usually achieved by projecting the 4D world to a 3D volume and then projecting that to a 2D plane.  

---

## 0 answers

