/* Rectangle en 2D */ /* */ /* Auteur: Nicolas JANEY */ /* nicolas.janey@univ-fcomte.fr */ /* Novembre 2010 */ #include #include #include #include "Rectangle2D.h" #include "Position2D.h" #include "Trace.h" Rectangle2D::Rectangle2D(void) { ig = new Position2D(); sd = new Position2D(); } Rectangle2D::Rectangle2D(Position2D *p1,Position2D *p2) { ig = new Position2D(p1); sd = new Position2D(p2); } Rectangle2D::Rectangle2D(Rectangle2D *s) { ig = new Position2D(s->ig); sd = new Position2D(s->sd); } Rectangle2D::~Rectangle2D(void) { delete(ig); delete(sd); } void Rectangle2D::print(void) { ig->print(); printf("\n"); sd->print(); printf("\n"); } static int round(double v) { return((int) (v + (( v > 0.0 ) ? 0.4999 : -0.4999))); } void Rectangle2D::trace(void) { traceSegment(round(ig->c[0]),round(ig->c[1]), round(ig->c[0]),round(sd->c[1])); traceSegment(round(ig->c[0]),round(ig->c[1]), round(sd->c[0]),round(ig->c[1])); traceSegment(round(sd->c[0]),round(sd->c[1]), round(ig->c[0]),round(sd->c[1])); traceSegment(round(sd->c[0]),round(sd->c[1]), round(sd->c[0]),round(ig->c[1])); }