PDA

View Full Version : problem of drawing circles on a sphere

grzesczwa
01-13-2013, 01:56 AM
For some time, trying to draw a circle on the sphere.
It comes to me.
Later this sphere with wheels trying to rotate around its axis.
But the wheels are spinning they are distorted. I want to go to the market in the x, y, z were further round

Please help as this to solve the problem.
Then he also plans to draw an ellipse

void GLWidget::paintGL()
{
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Wyczyszczenie okna bieżącym kolorem tła
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glColor3ub(0,0,34); // niebieski
glBegin(GL_QUADS);
glVertex2f(-20.1f, -20.1f);
glVertex2f(-20.1f, 20.1f);
glVertex2f( 20.1f, 20.1f);
glVertex2f( 20.1f, -20.1f);
glEnd();

glScaled(this->zoom,this->zoom,1);

// Wyzerowanie macierzy widoku modelu
glRotatef(-xRot / 16.0f, 1.0f, 0.0f, 0.0f);
glRotatef(yRot / 16.0f, 0.0f, 1.0f, 0.0f);
glRotatef(zRot / 16.0f, 0.0f, 0.0f, 1.0f);

paintCoordinates();

glRotated(180,0,0,0);
glColor3ub(255,0,34); // niebieski
funkcje f;
GLfloat kat;
glBegin(GL_LINE_STRIP);
daneStarsRA = f.deg2rad(70);
daneStarsDEC = f.deg2rad(70);

double x = sin(daneStarsRA) * cos(daneStarsDEC);
double y = -sin(daneStarsDEC);
double z = sin(daneStarsRA-M_PI/2) * cos(daneStarsDEC);
double x1,y1;

glBegin(GL_TRIANGLE_FAN);
for(kat = 0.0f; kat < (2.0f*M_PI); kat += (M_PI/32.0f))
{
x1 = (0.1f * cos(kat)) + x;
y1 = (0.1f * sin(kat)) + y;
glVertex3d(x1, y1, z);
}
glEnd();

glBegin(GL_LINE_STRIP);
daneStarsRA = f.deg2rad(0);
daneStarsDEC = f.deg2rad(0);

x = sin(daneStarsRA) * cos(daneStarsDEC);
y = -sin(daneStarsDEC);
z = sin(daneStarsRA-M_PI/2) * cos(daneStarsDEC);

glBegin(GL_TRIANGLE_FAN);
for(kat = 0.0f; kat < (2.0f*M_PI); kat += (M_PI/32.0f))
{
x1 = (0.1f * cos(kat)) + x;
y1 = (0.1f * sin(kat)) + y;
glVertex3d(x1, y1, z);
}
glEnd();

glBegin(GL_LINE_STRIP);
daneStarsRA = f.deg2rad(30);
daneStarsDEC = f.deg2rad(30);

x = sin(daneStarsRA) * cos(daneStarsDEC);
y = -sin(daneStarsDEC);
z = sin(daneStarsRA-M_PI/2) * cos(daneStarsDEC);

glBegin(GL_TRIANGLE_FAN);
for(kat = 0.0f; kat < (2.0f*M_PI); kat += (M_PI/32.0f))
{
x1 = (0.1f * cos(kat)) + x;
y1 = (0.1f * sin(kat)) + y;
glVertex3d(x1, y1, z);
}
glEnd();

glMatrixMode(GL_MODELVIEW);
glPopMatrix();

glMatrixMode(GL_PROJECTION);
glPopMatrix();

glPopAttrib();
}

Regards
Gregory