Results 1 to 9 of 9

Thread: homogenous coords

  1. #1
    Junior Member Newbie
    Join Date
    May 2000
    Posts
    6

    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 ......

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    London
    Posts
    503

    Re: homogenous coords

    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.

  3. #3
    Senior Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    763

    Re: homogenous coords

    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.

    cheers,
    John

  4. #4
    Senior Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    763

    Re: homogenous coords

    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)
    etc.

    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

    cheers,
    John

  5. #5
    Junior Member Newbie
    Join Date
    May 2000
    Posts
    6

    Re: homogenous coords

    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[0] + Set.y * T[4] + Set.z *
    T[8] + T[12];
    y = Set.x * T[1] + Set.y * T[5] + Set.z *
    T[9] + T[13];
    z = Set.x * T[2] + Set.y * T[6] + Set.z *
    T[10] + T[14];

    now at this point I think I would do a x/w y/w z/w to get the cartesian coords...
    Is this correct????

  6. #6
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    France
    Posts
    880

    Re: homogenous coords

    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 :

    newX=T[0]*x+T[4]*y+T[8]*z+T[12]*w;
    newY=T[1]*x+T[5]*y+T[9]*z+T[13]*w;
    newZ=T[2]*x+T[6]*y+T[10]*z+T[14]*w;
    newW=T[3]*x+T[7]*y+T[11]*z+T[15]*w;

    And then :

    cartesian_x=newX/newW;
    cartesian_y=newY/newW;
    cartesian_z=newZ/newW;
    cartesian_w=newW/newW; // =1 ! //

    That's what I think you should do but, to be honest, I have never used this w coordinate...

    Regards.

    Eric

  7. #7
    Senior Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Adelaide, South Australia, Australia
    Posts
    763

    Re: homogenous coords

    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...)

    cheers,
    John


    [This message has been edited by john (edited 05-25-2000).]

  8. #8
    Junior Member Newbie
    Join Date
    May 2000
    Posts
    6

    Re: homogenous coords

    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 ????

  9. #9
    Senior Member Frequent Contributor
    Join Date
    Feb 2000
    Location
    France
    Posts
    880

    Re: homogenous coords

    Have a look there :
    http://heron.cc.ukans.edu/ebt-bin/np...per/OpenGL_PG/

    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 !

    Good luck.

    Eric

    P.S. : I had to use that when parsing .ASE files and it worked.

Similar Threads

  1. Homogenous Cordinates
    By soxfan5614 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-16-2013, 10:37 PM
  2. Homogenous, Normalized Device Coords and clipping
    By Plutonium in forum OpenGL: General
    Replies: 22
    Last Post: 12-01-2010, 10:29 AM
  3. Depth problem with translating screen coords to world coords
    By Bryan_dup1 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 04-13-2006, 05:02 AM
  4. question about homogenous coordinate
    By godhand in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-14-2004, 04:06 PM
  5. homogenous projections/clipping
    By genghis37 in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 06-22-2002, 03:32 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean