How to ...

This is a discussion on How to ... within the Game Programming forums, part of the General Programming Boards category; How to draw a polyhedron and dedocahedron in turbo c ? any one has any idea?...

  1. #1
    Registered User planet_abhi's Avatar
    Join Date
    Oct 2002
    Posts
    92

    How to ...

    How to draw a polyhedron and dedocahedron in turbo c ?

    any one has any idea?
    AbHHinaay

  2. #2
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Posts
    5,439
    Sure.

    void DrawPolyhedron() and DrawDedocahedron() should do the trick. Do your own homework. Post questions to specific problems you're having with *your* code.
    Code:
    int main(void){srand(time(0));for(double l=rand(),l0=0,l00=0;;l0+=0.1){for(double l000=0;l000
    <1;l000+=.001,l+=((double)rand()/RAND_MAX)/0x64,l00+=((sin(l*0x8*atan(l0)*l000-(l0*0x8*atan
    (l)))*0.5)+0.5)){l00-=floor(l00);for(size_t l0000=0,l00000=(size_t)(0x50*(l00));l0000<l00000;++l0000
    )putchar(0x20);putchar(0x61+(int)((double)rand()/RAND_MAX*0x1a));putchar('\n');}}return 0;}

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Posts
    5,439
    Just abstract the problem. You need to draw lines. So write a function:

    void DrawLine(int start_x, int start_y, int end_x, int end_y);

    You'll need a function that translates lengths and angles into variables you can pass into the drawing function.

    void CalcLine(double theta, int length, int * start_x, int * start_y, int * end_x, int * end_y);

    ...etc, etc.

    Break it up into smaller pieces, make them work, and then reassemble. Presto.
    Code:
    int main(void){srand(time(0));for(double l=rand(),l0=0,l00=0;;l0+=0.1){for(double l000=0;l000
    <1;l000+=.001,l+=((double)rand()/RAND_MAX)/0x64,l00+=((sin(l*0x8*atan(l0)*l000-(l0*0x8*atan
    (l)))*0.5)+0.5)){l00-=floor(l00);for(size_t l0000=0,l00000=(size_t)(0x50*(l00));l0000<l00000;++l0000
    )putchar(0x20);putchar(0x61+(int)((double)rand()/RAND_MAX*0x1a));putchar('\n');}}return 0;}

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,515
    Code:
    
    struct ipoint2D
    {
      int x;
      int y;
    };
    
    void Draw(ipoint2D *points, int numpoints)
    {
      for (int i=0;i<numpoints;i++)
      {
         int x1=points[i].x;
         int y1=points[i].y;
         int x2=points[i+1].x;
         int y2=points[i+1].y;
         DrawLine (x1,y1,x2,y2);
      }
       int x1=points[0].x;
       int y1=points[0].y;
       int x2=points[numpoints].x;
       int y2=points[numpoints].y;
       DrawLine(x1,y1,x2,y2);
    }
    This does not show how to draw a line nor does it show how to create the figure. I leave that as an exercise for you to figure out.
    One hint though - if you want 20 sides to the figure you would divide 360 by 20 and increment the angle by that much each time you draw a 'side'
    Arrogance breeds bad code

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21