/* Create a sphere centered at c, with radius r, and precision n Draw a point for zero radius spheres Use CCW facet ordering "method" is 0 for quads, 1 for triangles (quads look nicer in wireframe mode) Partial spheres can be created using theta1->theta2, phi1->phi2 in radians 0 < theta < 2pi, -pi/2 < phi < pi/2 */ void CreateSphere(XYZ c,double r,int n,int method, double theta1,double theta2,double phi1,double phi2) { int i,j; double jdivn,j1divn,idivn,dosdivn,unodivn=1/(double)n,ndiv2=(double)n/2,t1,t2,t3,cost1,cost2,cte1,cte3; cte3 = (theta2-theta1)/n; cte1 = (phi2-phi1)/ndiv2; dosdivn = 2*unodivn; XYZ e,p,e2,p2; /* Handle special cases */ if (r < 0) r = -r; if (n < 0){ n = -n; ndiv2 = -ndiv2; } if (n < 4 || r <= 0) { glBegin(GL_POINTS); glVertex3f(c.x,c.y,c.z); glEnd(); return; } t2=phi1; cost2=cos(phi1); j1divn=0; for (j=0;j