void Polygon::draw(){ unsigned int i; Dot d; glLoadIdentity(); glTranslatef(position.getX(), position.getY(), 0); glRotated(direction, 0, 0, 1); glColor3f(color[RED], color[GREEN], color[BLUE]); glBegin(GL_LINES); for(i=0; i<lines_vertex.size(); i++){ d = lines_vertex.at(i); glVertex2f(d.getX(), d.getY()); } glEnd(); glBegin(GL_LINE_STRIP); for(i=0; i<strip_vertex.size(); i++){ d = strip_vertex.at(i); glVertex2f(d.getX(), d.getY()); } glEnd(); glBegin(GL_LINE_LOOP); for(i=0; i<loop_vertex.size(); i++){ d = loop_vertex.at(i); glVertex2f(d.getX(), d.getY()); } glEnd(); }
float Dot::whichSide(Dot a, Dot b){ float xa = a.getX(); float ya = a.getY(); float xb = b.getX(); float yb = b.getY(); return (xa*yb - ya*xb + y*(xb-xa) + x*(ya-yb)); }
float Dot::operator*(Dot p){ return (x*p.getX() + y*p.getY()); }