diff --git a/pmc/cube.cc b/pmc/cube.cc --- a/pmc/cube.cc +++ b/pmc/cube.cc @@ -6,8 +6,14 @@ #include #include +using namespace algebra; + Cube::Cube (Surface * s) { + surface = s; + name = "Cube"; + height = 25; + P[0] = new Vector (0, 0); P[1] = new Vector (100, 0); P[2] = new Vector (100, 100); @@ -17,16 +23,15 @@ P[5] = new Vector (125, 25); P[6] = new Vector (125, 125); P[7] = new Vector (25, 125); - - surface = s; - height = 25; } -Cube::Cube (Surface * s, Vector& p1, Vector& p2, Vector& p3, Vector& p4, int h) +Cube::Cube (Surface * s, Vector & p1, Vector & p2, Vector & p3, Vector & p4, int h) { + surface = s; + name = "Cube"; height = h; - surface = s; - Vector location(h/2, h/2); + + Vector location (h / 4, h / 4); P[0] = new Vector (p1); P[1] = new Vector (p2); @@ -39,6 +44,21 @@ } } +Cube::Cube (Surface * s, Vector p[4], int h) +{ + surface = s; + name = "Cube"; + height = h; + + Vector location (h / 4, h / 4); + + for (int i = 0; i < 4; i++) { + P[i] = new Vector (p[i]); + P[4 + i] = new Vector (*P[i]); + *P[4 + i] = *P[i] + location; + } +} + Cube::~Cube () { for (int i = 0; i < 8; i++) { @@ -58,7 +78,9 @@ void Cube::show () { - /* Implement some Sanity Checks */ + /* + * Implement some Sanity Checks + */ int height = surface->getHeight (); surface->drawLine (P[0]->X (), P[0]->Y (), P[1]->X (), P[1]->Y ());