nythrix's picture

Homogeneous coordinates

I've been trying to grasp this concept but it's proving a bit hard. During development of my math bits I got used to this:
1) [x,y,z,1] is a "point" which can be transformed in any way by matrix multiplication. It is subject to translations, rotations, etc.
2) [x,y,z,0] is a "vector". Apart from being invariant to translations (ie. you can't "move" it) it works the same as (1). Normals face the same way no matter where they are so this would be a normal typically.
Logically speaking I'm fine at the moment. But I want to merge these structures so I thought about going with a general 4D vector. I've read through wikipedia and a bunch of other sites but I have some logical problems.
A) For example adding a vector to a point yields:
[px,py,pz,1] + [vx,vy,vz,0] = [vx,vy,vz,0]
So moving a point along a vector yields the vector...?
B) Also implementing the general formula (same page, scalars ignored):
[Xa,Ya,Za,Wa] + [Xb,Yb,Zb,Wb] = [WbXa + WaXb, WbYa + WaYb, WbZa + WaZb, WaWb]
gives [0,0,0,0] for ANY two vectors (Wa=Wb=0). Instead it should be [Xa+Xb, Ya+Yb, Za+Zb, 0] which on the other hand doesn't fit into the general formula IMHO.
Anyone been dealing with this? There's a good chance I got it all wrong so a kick in the teeth might be appreciated aswell :-D

http://en.wikipedia.org/wiki/Homogeneous_coordinates


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
martinsm's picture

[px,py,pz,1] + [vx,vy,vz,0] = [vx,vy,vz,0]
So moving a point along a vector yields the vector...?

I would read that as - moving point in direction and length by given vector.

[Xa,Ya,Za,Wa] + [Xb,Yb,Zb,Wb] = [WbXa + WaXb, WbYa + WaYb, WbZa + WaZb, WaWb]
This forumula (from wikipedia) is for "addition of a pair of projected points".
If you want to add simple vectors you should add them as simple vector addition [Xa+Xb, Ya+Yb, Za+Zb, 0+0]

nythrix's picture

[Point+Vector]
Let me rephrase that with an example: [3,2,4,1] + [1,1,-2,0] = [4,3,2,1]. In other words I would expect the vector to shift the point to another place. Or not?

[General case]
Citing the article:
The calculation can also be carried over without distinguishing between cases, similarly to the addition of two points:
[Xa,Ya,Za,Wa] + [Xb,Yb,Zb,Wb] = [WbXa + WaXb, WbYa + WaYb, WbZa + WaZb, WaWb]
Starting from this, you can re-obtain the formulas for above cases.

Are you saying this GENERAL formula doesn't actually work in all cases? Namely for points at infinity (w=0 ie. vectors)?

martinsm's picture

In other words I would expect the vector to shift the point to another place. Or not?
But that is what it did - it shifted point [3,2,4] to new locatio n - [4,3,2]. Because of vector [1,1,-2] - add 1 to X coordinate, add 1 to Y coordinate, and -2 to Z.

nythrix's picture

But that is what it did - it shifted point [3,2,4] to new locatio n - [4,3,2]. Because of vector [1,1,-2] - add 1 to X coordinate, add 1 to Y coordinate, and -2 to Z.
Uhm, yes. That is what I EXPECT it to be, and I'm completely fine with that. But according to wikipedia it should be something completely different:
[3,2,4,1] + [1,1,-2,0] = [1,1,-2,0] <- THIS I don't get.