• 11
• 9
• 10
• 9
• 10

sphere from parametric equation

This topic is 3828 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi i am trying to draw a sphere from scratch. I am using the parametric equation of the sphere. x = sqrt( r*r - u*u ) cos angle; y = sqrt( r*r - u*u ) sin angle; z = u where u = -r to r angle = 0 to 2*PI r = radius I am not using the glusphere function as eventually i need to show lines piercing into the sphere and passing throug the center. And for that i need points which lie on the surface on the sphere(which would act as origin of the line) which i think i cannot get from glusphere. I am unable to produce a sphere from the above code. Some weird stuff coming up.
for(float i = -radius, theta = 0; i <= radius, theta <= 360; i += 0.01, theta += 5)
{

tempSpherePt[2] = i;

mpApp->spherePoints.push_back(tempSpherePt);

}

Could you please tell me the problem with the code or any other way i could implement the funcionality i need to implement ? Utk