Vector class for homogeneous coordinates
Hi all,
I am writing a vector class using homogeneous coordinates (x, y, z and w) for use with OpenGL. I wondered if this would change any of the standard operations on vectors with only x, y and z coordinates.
For example, is the inproduct still x1*x2 + y1*y2 + z1*z2 or is it something like x1*x2 + y1*y2 + z1*z2 + w1*w2? (I would guess the first). Is it as simple as keeping w always set to 1.0?
And of course, are there any nifty tricks I could do with that extra w coordinate besides translations?
Thanks,
-Leroy
Homogeneous coordinates correspond to points in projective space. The dot product of two points in the projective space doesn''t make a lot of sense. If you keep w=1.0, you are working in an affine chart (? It''s "carta afín" in Spanish).
I wish I could point you to a good book on Projective Geometry, but I haven''t found any. The best I have read is by Conway, but it was mostly 2D. I studied from my teacher''s notes. He had plans to make a book out of them, but I don''t think it has been published yet.
I wish I could point you to a good book on Projective Geometry, but I haven''t found any. The best I have read is by Conway, but it was mostly 2D. I studied from my teacher''s notes. He had plans to make a book out of them, but I don''t think it has been published yet.
Division of one component by another such as the perspective divide where (x'', y'')=(x*sz/z, y*sz/z) where sz is the z of the screen. Multiplying by sz isn''t any problem, but it is rather hard to get a matrix of constants to do division by a variable. With a bit of creativity it might be possible to get it to do bends, twists and tapers, but I have my doubts.
Keys to success: Ability, ambition and opportunity.
If you''re looking for a text on projective geometry, the first few chapters of Multiple View Geometry (sorry, can''t recall the author) are pretty good. It''s a computer vision work, but the geometry''s the same.
Thanks for your replies,
I only wonder why dot products (and maybe some other operations) wouldn''t make any sence in projective space (I found this term on the Internet too, but couldn''t picture it really well).
It is possible to write a dot product operation which has the same properties as the 3d equivalent:
DotProd(v1, v2) = (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z) /
(v1.w * v2.w)
Now my vector class includes the above operation and some others where equivalence in 3d was the starting point.
I only wonder why dot products (and maybe some other operations) wouldn''t make any sence in projective space (I found this term on the Internet too, but couldn''t picture it really well).
It is possible to write a dot product operation which has the same properties as the 3d equivalent:
DotProd(v1, v2) = (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z) /
(v1.w * v2.w)
Now my vector class includes the above operation and some others where equivalence in 3d was the starting point.
Thanks for your replies,
I only wonder why dot products (and maybe some other operations) wouldn''t make any sence in projective space (I found this term on the Internet too, but couldn''t picture it really well).
It is possible to write a dot product operation which has the same properties as the 3d equivalent:
DotProd(v1, v2) = (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z) /
(v1.w * v2.w)
Now my vector class includes the above operation and some others where equivalence in 3d was the starting point.
I only wonder why dot products (and maybe some other operations) wouldn''t make any sence in projective space (I found this term on the Internet too, but couldn''t picture it really well).
It is possible to write a dot product operation which has the same properties as the 3d equivalent:
DotProd(v1, v2) = (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z) /
(v1.w * v2.w)
Now my vector class includes the above operation and some others where equivalence in 3d was the starting point.
> DotProd(v1, v2) = (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z) /
> (v1.w * v2.w)
That works, but to do the same with other operations is more expensive, e.g. addition becomes
v3.x = v1.x / v1.w + v2.x / v2.w;
v3.y = v1.y / v1.w + v2.y / v2.w;
v3.z = v1.z / v1.w + v2.z / v2.w;
v3.w = 1;
If you do this you are in effect generating the 3D non-homogenous vector to do the addition. And if you need to do this a lot it may be better to store this vector instead of the 4D vector.
There''s not much use for the w component in 3D, and in general most calculations (e.g. addition, orthogonal transformation) leaveit at 1, so dividing by the w component is redundant. For the few operations that can result in w not equal to 1 it''s usual to divide though by w so it can be immediately reset to 1.
> (v1.w * v2.w)
That works, but to do the same with other operations is more expensive, e.g. addition becomes
v3.x = v1.x / v1.w + v2.x / v2.w;
v3.y = v1.y / v1.w + v2.y / v2.w;
v3.z = v1.z / v1.w + v2.z / v2.w;
v3.w = 1;
If you do this you are in effect generating the 3D non-homogenous vector to do the addition. And if you need to do this a lot it may be better to store this vector instead of the 4D vector.
There''s not much use for the w component in 3D, and in general most calculations (e.g. addition, orthogonal transformation) leaveit at 1, so dividing by the w component is redundant. For the few operations that can result in w not equal to 1 it''s usual to divide though by w so it can be immediately reset to 1.
John BlackburneProgrammer, The Pitbull Syndicate
quote:
Original post by leroy
DotProd(v1, v2) = (v1.x * v2.x + v1.y * v2.y + v1.z * v2.z) /
(v1.w * v2.w)
That''s not a dot product, I believe, because it does not repect the definition (I don''t know why exactly, but there''s something wrong here).
And anyway, this dot product does not work at all. As has been said before, the dot product does not make any sense for points; it only makes sense for vectors. Vectors have w = 0, so your dot product would have a division by 0.
Cédric
This can get a little bit too hardcore. There is a very good reason why your "projective dot product" is a bad object. In the post-Grothendieck era of Math, we don''t just speak about spaces. Spaces are the objects of a cathegory, but you also need the morphisms. That means that when you study vector spaces, you study them together with linear mappings, when you study topological spaces, you study them with continuous functions, rings with ring homomorphisms, and so on. A vector space with an internal product (like the dot product) is an euclidean space, which shall be studied together with metric-preserving linear mappings (movements). In plain[er] words, the dot product makes sense because if you change your coordinates to another orthonormal reference, the dot product is preserved.
Projective spaces are studied together with projectivities, which are quite wild transformations. The main quantity that projectivities preserve is the cross ratio of four points, but they clearly don''t preserve your wanna-be-product. So it''s not an operation that fits naturally in homogeneous coordinates.
Projective spaces are studied together with projectivities, which are quite wild transformations. The main quantity that projectivities preserve is the cross ratio of four points, but they clearly don''t preserve your wanna-be-product. So it''s not an operation that fits naturally in homogeneous coordinates.
quote:
Original post by cedricl
That''s not a dot product, I believe, because it does not repect the definition (I don''t know why exactly, but there''s something wrong here).
Inner Product definition
The "dividing by w" deal kills the first two definitions, which states that the projection of the sum of two vectors on a third vector is equal to the sum of the individual projections, and vice versa.
I''m not an expert on this form of matrices, but it seems to me there''s a fundamental problem in treating these as in a normal vector space since the fourth coordinate is in a different space than the first three. The first three coordinates are in R, while the fourth is in a boolean space. This might be a "deal-breaker" as they say, but I''m not sure.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement