#include<stdlib.h>
#include <GL/glut.h>
#include <math.h>
const float DEG2RAD = 3.14159/180;
const float xradius=-0.4f;
const float yradius=-0.3f;
//画椭圆
void putpixel(int xc,int yc,int x,int y){
glBegin(GL_POINTS);
glVertex3f(xc+x,yc+y,0);
glEnd();
}
void drawEllipse(int xc,int yc,int a,int b) {
int x,y;
float d1,d2;
x=0; y=b;
d1=b*b+a*a*(-b+0.25);
putpixel(xc,yc,x,y);
putpixel(xc,yc,-x,-y);
putpixel(xc,yc,-x,y);
putpixel(xc,yc,x,-y);
while(b*b*(x+1)<a*a*(y-0.5)){
if(d1<0){
d1+=b*b*(2*x+3);
x++;
}else{
d1+=b*b*(2*x+3)+a*a*(-2*y+2);
x++;
本内容试读结束,登录后可阅读更多
下载后可阅读完整内容,剩余3页未读,立即下载