View Full Version : homogenous coords
I've done some reading on opengls' use of homogenous coordinates and somewhere it said that unless changed, the w value(x , y ,z ,w) is 1.00.. I've transformed and rotated the verts myself and compared them to the api's and they are not the same and dividing by 1.00 is certainly not going to give me what I want.....I'm obviously missing something... any help would be appreciated ......
05-24-2000, 09:12 AM
How are you doing the translations? If you're adding two Vector4 coords with implicit W==1, using standard vector addition rules, the result will have W==2. AFAIK the "default W==1" only applies when multiplying a Vector4 by a matrix; I don't know about anything else.
the DEFAULT probably comes when you specify verticies with glVertex3f() and not ...4f(). after that, i reckon ogl can do what it wants with his homogenous coordinates.
BTW, about homogeneous coords:
lambda*(x, y, z, w) is the same point for all lambda. so, the point
(1, 2, 3, 1) == (2, 4, 6, 2) == (3, 6, 9, 3)
to convert homogeneous to cartesian coordinates, you divide x, y & z by w. (ie. (3/3, 6/3, 9/3) == (2/2, 4/2, 6/2) == (1, 2, 3)
hope this helps clear things up
That's what I'm tring to find, the w value to convert back to cartesian coords. Maybe I'm going about this wrong..
Here's what I'm doing ...after
glRotatef() and glTranslatef() I'm getting the matrix with
glGetFloatv() and transforming with something like this...
x = Set.x * T + Set.y * T + Set.z *
T + T;
y = Set.x * T + Set.y * T + Set.z *
T + T;
z = Set.x * T + Set.y * T + Set.z *
T + T;
now at this point I think I would do a x/w y/w z/w to get the cartesian coords...
Is this correct????
Your multiplication for x,y and z is correct (no doubt about that !).
On the other hand, I can not answer for your w problem...
I would have thought you should do :
And then :
cartesian_w=newW/newW; // =1 ! //
That's what I think you should do but, to be honest, I have never used this w coordinate...
yes; Eric is right.
oh, except when you convert homogeneous to cartesian coordinates, the w is lost (and so dividing w by w is irrelevent)
and w does not necessarily == 1. it just has to be non zero (if w is zero, the point is at infinity...)
[This message has been edited by john (edited 05-25-2000).]
Thanks for the replies... I tried the solutions but still not getting the results I want..... Maybe it's the way I handle the polygons normal... I'm adding the normal to a vertice and transforming it just like the a regular vertices and then subtracting it from this vert when I need it. What I'm trying to do is implement collision detection and I know the algo works with my own transformations but fails with this...any ideas ????
Have a look there :
It is the OpenGL programming guide.
They explain that when the vertices are transformed by a matrix M, the normals are transformed by (M-1)t which means the transpose of the invert of M.
That's probably where your problem is !
P.S. : I had to use that when parsing .ASE files and it worked.
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.