We haven't really talked about negative homogeneous coordinates, or reflection as a transformation in homogeneous coordinates—since negative homogeneous coordinates would have the vector pointing in the opposite direction, it could conceivably be used as a roundabout way of reflection by keeping the extra coordinate negative until it needed to be scaled back, where the negative would transfer into the x and y coordinates.
Are negative homogeneous coordinates used for anything, well, more useful?
This jump confused me a little bit; is the effect of using homogeneous coordinates to essentially let us think about transformations as a set of shapes rather than an explicit operation?
@jzhanson Nice idea! Weirdly enough, the trick you propose will depend on whether you're working in an even or odd dimension. For instance, suppose we have a point (x,y) in 2 dimensions, and let (x,y,1) be the corresponding homogeneous coordinates. If we negate the homogeneous coordinate we get (x,y,-1), and when we project back to 2D we get coordinates (x/-1,y/-1) = (-x,-y) = -(x,y). But there's no way this transformation is a reflection; for instance, the corresponding matrix is
[ -1 0 ]
[ 0 -1 ]
which has determinant -1 x -1 = +1. Equivalently, we can think of it as the matrix
[ cos(pi) sin(pi) ]
[ -sin(pi) cos(pi) ]
in other words, a rotation by 180 degrees.
What happens in 3D? The coordinates (x,y,z) turn into homogeneous coordinates (x,y,z,1), and if we negate the last coordinate we get (x,y,z,-1). Projecting back to 3D then gives (x/-1,y/-1,z/-1), which looks like we applied the matrix
[ -1 0 0 ]
[ 0 -1 0 ]
[ 0 0 -1 ]
The determinant of this matrix is -1 x -1 x -1 = -1, which means we did apply a reflection (but across which axis?).
@jzhanson As for whether homogeneous coordinates are used for anything more useful: yes, absolutely! The two main things we'll see them used for in the basic rasterization pipeline are:
They also let us distinguish between points (homogeneous coordinate 1) and vectors (homogeneous coordinate 0), which will transform differently. When we apply a transformation to our scene we do want to translate the points, but we don't want to translate the normals. For instance, if we translate a cube along a vector (a,b,c), the normal vector (0,0,1) sticking straight "up" from the top of the cube should not become (a,b,c+1); it should still just be (0,0,1)! But homogeneous coordinates save us here---consider that for any vector [Nx,Ny,Nz,0] we have
[ 1 0 0 a ][Nx] [Nx]
[ 0 1 0 b ][Ny] = [Ny]
[ 0 0 1 c ][Nz] [Nz]
[ 0 0 0 1 ][0 ] [0 ]
whereas for any point [Px,Py,Pz,1] we have
[ 1 0 0 a ][Px] [Px+a]
[ 0 1 0 b ][Py] = [Py+b]
[ 0 0 1 c ][Pz] [Pz+c]
[ 0 0 0 1 ][1 ] [ 1 ].
On the other hand, if we apply a rotation in homogeneous coordinates, both points and vectors will get rotated, as we would hope. (Do you see why?) For instance, rotating a cube should definitely rotate its normals.
More broadly, homogeneous coordinates are used to nicely represent all sorts of transformations in geometry and physics, though these aren't directly relevant to our class. If you're interested, though, here are some pointers:
@Log You can think of homogeneous coordinates as acting on individual points, or on sets of points ("shapes"). The observation is simply that since each point in 2D corresponds to a line in homogeneous 3D, a shape in 2D corresponds to a sort of "cone of shapes" in 3D. For instance, a 2D disk around the origin will literally become a circular cone. Thinking about how transformations act on this cone can help provide some intuition for how they act on the original 2D shape. For instance, shearing of the 3D cone corresponds to translation of the 2D shape.
With regards to the question posed by @keenan above...
In 2D, we had the matrix
[ -1 0 ]
[ 0 -1 ]
which, while a 180-degree rotation, can also be interpreted as a reflection across the x-axis followed by a reflection across the y-axis, or in other words the product of these two matrices:
[ 1 0 ] [ -1 0 ]
[ 0 -1 ] [ 0 1 ]
We can interpret the 3D case in the same way:
[ -1 0 0 ] [ 1 0 0 ] [ 1 0 0 ] [ -1 0 0 ]
[ 0 -1 0 ] = [ 0 1 0 ] [ 0 -1 0 ] [ 0 1 0 ]
[ 0 0 -1 ] [ 0 0 -1 ] [ 0 0 1 ] [ 0 0 1 ]
...but it seems like the question "across which axis" doesn't have a good answer, because the determinant of -1 arose from three separate reflections rather than a single one; in fact, rather than reflecting across an axis (a plane in this case), we're actually reflecting "through a point", specifically the origin! We were actually doing the same thing in 2D, but it happens that reflecting through the origin in 2D is the same as rotating 180 degrees.
I guess this idea could generally be extended to other reflections as well, where the object being reflected "through" would be the intersection of the constituent reflections; so a reflection across the x-axis (really, across the y-z plane) followed by a reflection across the y-axis (really, across the x-z plane) could be a reflection "through the z-axis", which makes geometric sense considering what it actually does in space (decomposing the vector into two components, one spanned by the object -- in this case, the z-axis -- and one normal to it, and then negating the normal component, just as is done by any other more-common reflection). This is even consistent with the result we got in 2D, since the only point on the z-axis when we project down to 2D is the origin.
(Edited for formatting.)
How would shear in 2D-H be visualized in this scenario?