# Are there standards for how to structure 4D vector math?

This is a somewhat subjective question, but I am also asking if there are a standards. This question is about the general math but some of it is in the context of computer programming.

Some specific questions and thoughts I had:

• W seems to be is the most common letter to add compared to 3D vectors, but there may be others.

• Should the components be ordered XYZW or WXYZ? That is, should X or W be considered the first component, and should Z or W be the last component? For constructors and printing.

• Building on the above, which should be discarded when converting to a 3D vector? Probably W.

• What should the "default" values of a 4D vector be? I would assume (0, 0, 0, 0) but some code I've found makes 1 the default for W.

• What kind of methods not found in 2D and 3D vector math are useful for 4D vector math?

There aren’t standards per se, but there are certainly context-dependent conventions. From what I’ve seen, they depend mainly on whether you consider the tuple as inhomogeneous Cartesian coordinates of a point/vector in $\mathbb R^4$ or homogeneous coordinates of a point/vector in the projective space $\mathbb{RP}^3$. In the latter case, which is what it appears you’re asking about, the “extra” coordinate is generally labeled $w$ in the computer graphics and computer vision literature. This “extra” coordinate generally comes last in these contexts. This corresponds to the common model of the projective plane as the plane $z=1$ in $\mathbb R^3$ and similarly for $\mathbb{RP}^3$ embedded in $\mathbb R^4$.
You don’t exactly “discard” one of the components when you convert from homogeneous to inhomogeneous coordinates. Mathematically speaking, to find the point in three-dimensional space that a 4-element homogeneous coordinate vector $\mathbf p = (x,y,z,w)$, you fix a point $O$ in $\mathbb R^4$ and a three-dimensional affine subspace that doesn’t contain the “home” point and find the intersection of the ray that originates at $O$ and has direction vector $\mathbf p$ with the subspace. The conventional choice is $O=(0,0,0,0)$ and the affine subspace $w=1$, from which you get the conversion “divide through by the last coordinate and then drop it.” If you’ve chosen the “extra” coordinate to be the first instead, then that’s the one that carries the homogeneous “scale factor.” Just be consistent.
As for a default value, that should really be whatever makes the most sense for your application. That said, there are “natural” choices. Looking again at homogeneous coordinates, $(0,0,0,0)$ doesn’t correspond to any point or vector in $\mathbb{RP}^3$. That makes it a good candidate for an invalid value. If you want to initialize to a valid value, on the other hand, $(0,0,0,1)$ is probably a good choice since it corresponds to the origin.