1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#include "Quadralateral.h"
#include <iostream>
Quadralateral::Quadralateral(int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4)
{
X1 = x1; // memberwise assignment
Y1 = y1;
X2 = x2;
Y2 = y2;
X3 = x3;
Y3 = y3;
X4 = x4;
Y4 = y4;
}
bool Quadralateral::isRectangle() // this is correct...i think
{
double diag1, diag2;
diag1 = sqrt(pow(double(X3 - X1),2) + pow(double(Y3 - Y1),2));
diag2 = sqrt(pow(double(X4 - X2),2) + pow(double(Y4 - Y2),2));
if(abs(diag1 - diag2) < .000001)
return true;
else
return false;
}
bool Quadralateral::isSquare()
{
double diag1, diag2, side1, side2, side3, side4;
diag1 = sqrt(pow(double(X3 - X1),2) + pow(double(Y3 - Y1),2));
diag2 = sqrt(pow(double(X4 - X2),2) + pow(double(Y4 - Y2),2));
side1 = (X1+Y1);
side2 = (X2+Y2);
side3 = (X3 + Y3);
side4 = (X4 + Y4);
if ((abs(diag1 - diag2) < .000001) && (side1 == side3)) // is this the right way to do this?
return true;
else
return false;
}
Quadralateral::~Quadralateral(void)
{
}
|