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
    Location
    Waterloo, Texas
    Posts
    5,652
    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:
    #include <ip.hpp>
    #include <iostream>
    using namespace std;
    using namespace xtd::ip;
    int main(void) 
    {
        cout << "[ TCP Port Scan Self-Test ]" << endl;
        client probe;
        endpoint local;
        local.address = "127.0.0.1";
        local.protocol = IPPROTO_TCP;
        for(local.port = 0; local.port < (1 << 16); ++local.port)
        {
            if(probe.open(local))
                cout << "Listening: ";
            else
                cout << "No Response: ";
            cout << local.port << endl;
        }    
    }

  3. #3
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,652
    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:
    #include <ip.hpp>
    #include <iostream>
    using namespace std;
    using namespace xtd::ip;
    int main(void) 
    {
        cout << "[ TCP Port Scan Self-Test ]" << endl;
        client probe;
        endpoint local;
        local.address = "127.0.0.1";
        local.protocol = IPPROTO_TCP;
        for(local.port = 0; local.port < (1 << 16); ++local.port)
        {
            if(probe.open(local))
                cout << "Listening: ";
            else
                cout << "No Response: ";
            cout << local.port << endl;
        }    
    }

  4. #4
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,590
    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'

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