4 ms·
I'm going to complain about this every chance I get. A 2D vector, we generally store as [x, y, 0]. What's the extra 0? The homogeneous coordinate. A 2D poin
by VikingCoder 8y ago
I'm going to complain about this every chance I get.
A 2D vector, we generally store as [x, y, 0]. What's the extra 0? The homogeneous coordinate.
A 2D point, we generally store as [x, y, 1]. That extra 1 is the homogeneous coordinate, and since it's there, it means "and apply translations!"
If I have a 2D transform, I put the translation component in the last row or column, depending on if you pre-multiply or post-multiply (I can never remember which).
When I transform a vector by that matrix, the 0 in the homogeneous coordinate means translation doesn't apply.
Perfect!
But what if I have a 3D vector? Well... I end up with [x, y, z, 0], right?
Ugh.
If instead, we stored the homogeneous coordinate in the FIRST position, [0, x, y] for 2D, and [0, x, y, z] for 3D, etc. then it's just a sparse vector! Set the values you want to! [0] is the 0-vector in any number of dimensions!
[1] is the origin point in any number of dimensions!
Why did we put the homogeneous coordinate last in all our internal representations? It was so dumb!
- twtw 8y agoI don't follow. What do we gain by moving the homogeneous coordinate from last position to first? I don't understand this: > then it's just a sparse vector! Set the variables you want to! Or this: > [1] is the origin point in any number of dimensions. Could you clarify? Also, I don't think this book even discusses homogeneous coordinates. It would be sort of unusual for this type of general text and the only mention of "homogeneous" in the index is "homogeneous equation."
- edflsafoiewq 8y agoI think what's meant is that by putting it first, you can always treat any point in P^n as a point in P^m by just ignoring the extra numbers if m < n or by treating the missing numbers as all being 0 if m > n. That is the point in P^2, [1 x y], can also be regarded as the point [1 x] in P^1, the point [1 x y 0] in P^3, the point [1 x y 0 0] in P^4, etc. This is in contrast to putting it last, where if you have [x y 1] in P^2 and you want the point in P^1 you need to allocate a new list [x 1], etc. The vector is sparse in the sense that you can regard a point as being an infinitely long list of numbers of which we are sparsely giving only that prefix that is non-zero (like how you can regard a decimal numeral as being an infinitely long list of digits, all the ones that are missing being 0). [1] is the origin point in any dimension because it is [1] in P^0, [1 0] in P^1, [1 0 0] in P^2, etc.
- deleted 8y ago[deleted]
- starmole 8y agoI hope you are just trolling. Homogeneous coordinates are for projection, not for selecting translation.
- twtw 8y agoHomogeneous coordinates allow for affine transformations to be represented and performed with a matrix multiply. This includes perspective projection and translation. One of the use cases for homogeneous coordinates is certainly to be able to achieve translation.
- chengiz 8y agoWith due respect, who is "we" and what are you talking about? The book does not as much as mention a homogeneous coordinate and uses 2-arrays for 2D vectors.
- VikingCoder 8y agoI'm off on a tangent unrelated to the book. "we" is computer programmers who deal with vectors and points. Mostly graphics, physics, games, etc.
- joppy 8y agoTechnically the projective coordinate (3,2,1) should be exactly the same as (6,4,2), and every nonzero multiple thereof. So it’s not really correct to say that (x, y, 0) represents a vector, or that adding these projective coordinates is vector addition. Vector addition is represented by an identity matrix with the x, y coordinates in the rightmost column.