Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: sphere construction

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    5

    Post sphere construction

    hi i am beginner to opengl.. i have a question. while constructing a sphere by subdividing the tetrahedron why are v suppose to normalize the points that v obtain during subdivision process ? what is the logic involved in this ?

    code for normalizing is this :

    void normal(GLfloat *p)
    {
    float d=0.0;
    int i;
    for(i=0;i<3;i++) d+=p[i]*p[i];
    d=sqrt(d);
    if(d>0.0) for(i=0;i<3;i++) p[i]/=d;
    }
    Last edited by supreeth; 05-20-2012 at 04:49 AM.

  2. #2
    Member Regular Contributor Rosario Leonardi's Avatar
    Join Date
    Aug 2008
    Location
    Italy
    Posts
    352
    In your question I don't understand if you're computing the normal or the position of the vertex.
    -The normal is a vector that represent the normal of the surface in a point, and it's only used to compute that shading of the surface. The shading usually depend on the cosine of angle between vector. Scalar product is used to fast compute the cosine, but scalar product between V1 and V2 is cos(a)*|V1|*|V2| if both V1 and V2 are normalized you assume that |V1| is one and you don't need to divide by |V1|*|V2| to compute cos(a). Most of the code around there assume that the normal are normalized.
    - Position, don't need to be normalized. It represent a position in local space. If you found the code on the web, maybe the author want a sphere of radius one so the dimension of the sphere can be easily controlled by transformation matrix.
    ~ ~ I tell you, realtime 3D is made of blood, sweat and screams! ~ ~

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    5
    hey.. i found this code in some computer graphics text.. according that book he is "Re-normalizing midpoints to lie on unit sphere"... i dint understand the meaning of "Re-normalize midpoints to lie on unit sphere".. please help me out..

  4. #4
    Junior Member Regular Contributor
    Join Date
    Dec 2009
    Posts
    178
    If you do subdivision without this normalizing step, the new midpoints will be inside the subdivided triangles, so in the end you'll still have a (finer tesselated) tetrahedron. To turn this tetrahedron into an approximate sphere, the new points are moved a bit, so that they fall onto the unit sphere (which is just math-speak for a sphere with radius 1).

    The points on the surface of the unit sphere all have a coordinate vector of length 1, so you can simply "normalize" the points to move them onto the unit sphere surface.

Posting Permissions

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