Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: Draw 3D Ellipso´des-OpenGl

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    11

    Draw 3D Ellipso´des-OpenGl

    hello,

    I develop an algorithm which allows to decompose 3D models into different parts.
    I need to represent each part (points cloud) with an ellipsoid. The center of the Ellipsoid is the gravity center of the cloud's part, and the diamers of its axis corresponding to the eigenvalues of the covariance matrix?

    Think you.
    Bil
    Last edited by bibi2canon_lmd; 07-04-2013 at 10:04 AM.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    188
    Start with a unit sphere at the origin.
    Scale it by the eigenvalues.
    Then translate it to the gravity center.

    Something like :

    Code :
       glTranslatef (gx, gy, gz);     // Translate to gravity center.
       glScalef (e1, e2, e3);         // Scale on each axis by eigenvalue
       Unit_Sphere ();                // Draw unit sphere at origin

    This code assumes that the ellipsoid axes are parallel to the world axes.

  3. #3
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    11
    Think's a lot
    I think that should be work!

  4. #4
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    11
    I tried by glutSolidSphere(1,30,30);
    That doesn't work?
    What do you mean by: "a unit sphere at the origin"?

    Thank you.

  5. #5
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    11
    I have to draw one ellipsoid on each gravity center of the classe.
    ex: 3 classes -> 3 ellipsoids!
    So, the gravity ccenter of each classe define the position of the corresponding ellipsoid.

    Think's.

  6. #6
    Junior Member Regular Contributor
    Join Date
    Apr 2012
    Location
    Los Angeles
    Posts
    188
    Quote Originally Posted by bibi2canon_lmd View Post
    I tried by glutSolidSphere(1,30,30); That doesn't work?
    Actually, that should give you a unit sphere centered at the origin.
    What do you mean when you say 'That doesn't work'? Do you see anything at all?
    First goal is to get a sphere of radius 1, centered at the origin to show up in a window.
    Are you able to do that?

  7. #7
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    11
    Hello!

    Before, I got spheres placed in a rang positiions!
    I find the problem. I forgot to put glPushMatrix() and glPushMatrix() before and after each ellipsoid drawing.
    Now, I need to know how I can oriented the Ellipsoids according to the eigenvectors?

    Think's a lot for you collaboration.

  8. #8
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    495
    Quote Originally Posted by bibi2canon_lmd View Post
    Now, I need to know how I can oriented the Ellipsoids according to the eigenvectors?
    Construct the matrix:
    Code :
    x1 x2 x3 cx
    y1 y2 y3 cy
    z1 z2 z3 cz
     0  0  0  1
    where [x1 y1 z1], [x2 y2 z2], and [x3 y3 z3] are the axes and [cx cy cz] is the centroid.

    Bear in mind that OpenGL uses column-major order by default.

  9. #9
    Junior Member Newbie
    Join Date
    Jul 2013
    Posts
    11
    Ok, but how I can use this matrix.
    I mean that I have use it with glRotatef(angle,x,y,z) or what?

    Think you.

  10. #10
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    495
    Quote Originally Posted by bibi2canon_lmd View Post
    Ok, but how I can use this matrix.
    With glLoadMatrix() or glMultMatrix().

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •