PDA

View Full Version : HexSwirl help :(

Ehsan_Liverpool
04-18-2011, 10:53 AM
Hi!
ive been working on this project for sometime now, and i just cant get my hexswirl function to work :( please help. its supposed to look like this: http://www.slidefinder.net/C/Computer_Graphics_using_OpenGL_3rd/15456597/p2 (the picture in slide 22 or 24)
I need this for a project which is due next week :(

by the way this is what ive come up with so far:

void Polygon11::draw(float n, float s, float a)
{
float r1;
double inc = 5.0/100;
double angleInc = 2*3.14159265/6.0;
double aaa;
for (int j = 0; j < 50; j++)
{
aaa = j* 3.14159265/180.0;
glBegin(GL_LINE_LOOP);
for (int i = 0; i < 6 ; i++)
{
a += angleInc;
glVertex2f(r1*s*cos((i*aaa)+10),r1*s*sin((i*aaa)+1 0)); glEnd();
r1 += inc;
}

}

mobeen
04-19-2011, 12:04 AM
Try this

I initially posted the code but have now removed it since this is your assignment and u should know how to do it.

Basically, the inner loop creates a hexagon. The outer loop reduces the radius and rotates the hexagon slightly (3 degrees). Which gives this output

http://www3.ntu.edu.sg/home2007/mova0002/test/hex.png

_arts_
04-19-2011, 02:16 AM
mobeen you're so kind :)

mobeen
04-19-2011, 02:29 AM
mobeen you're so kind :)
Hmmm atleast he tried his best to get it work.

After posting i realised I shouldn't have posted the code since this was an assignment given to him. May be i will edit my reply to remove the code.

Ehsan_Liverpool
04-25-2011, 08:53 AM
:D well i didn't get to see the code and fortunately got it to work by my self although it doesn't look half as good as yours :) thank you very much for your kind help though. i greatly appreciated you putting some time out for me and helping me. :) you cant imagine how happy i am that i finally got it to work! i really do like opengl and i am looking forwanrd to doing more and more projects using this wonderfull language :) i just wanted to ask and see if you might have any tips for me and what book i should be using.