How to draw a polyhedron and dedocahedron in turbo c ?
any one has any idea?
How to draw a polyhedron and dedocahedron in turbo c ?
any one has any idea?
AbHHinaay
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 <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
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 <cmath> #include <complex> bool euler_flip(bool value) { return std::pow ( std::complex<float>(std::exp(1.0)), std::complex<float>(0, 1) * std::complex<float>(std::atan(1.0) *(1 << (value + 2))) ).real() < 0; }
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.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); }
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'