Example Generators for PolygonsThe following program shows how to use the generators for #include <LEDA/geo/rat_polygon.h>
#include <LEDA/geo/rat_circle.h>
#include <LEDA/geo/rat_point.h>
#include <LEDA/numbers/rational.h>
#include <LEDA/graphics/window.h>
using namespace leda;
int main()
{
rat_point a(0,50),b(50,0), c(100,50);
rat_circle C1(a,b,c);
double epsilon1=0.00001;
rat_polygon P1=reg_n_gon(10,C1,epsilon1);
P1.normalize();
std::cout << P1 << std::endl;
rat_point d(25,50),e(50,25),f(75,50);
rat_circle C2(d,e,f);
double epsilon2=10;
rat_polygon P2=n_gon(10,C2,epsilon2);
P2.normalize();
std::cout << P2 << std::endl;
rational x1=35,y1=35,x2=65,y2=65;
rat_polygon P3=hilbert(5,x1,y1,x2,y2);
P3.normalize();
std::cout << P3 << std::endl;
window W(500,500);
W.open();
W.draw_polygon(P1.to_float());
W.draw_polygon(P2.to_float());
W.draw_polygon(P3.to_float());
W.display();
W.read_mouse();
return 0;
}
|
See also:Generators for Geometric Objects Advanced Data types for 2-D geometry Manual Entries: |