View Full Version : sphere construction

supreeth

05-20-2012, 05:43 AM

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;

}

Rosario Leonardi

05-20-2012, 08:46 AM

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.

supreeth

05-20-2012, 11:52 AM

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

mbentrup

05-20-2012, 10:54 PM

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.

Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.