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
|
class Point
{
public:
double x;
double y;
Point(double a, double b): x(a), y(b) {
};
class Triangle
{
public:
Point a, b, c;
Triangle():a(0,0),b(0,0),c(0,0){}
Triangle(Point i1,Point i2, Point i3) :a(i1), b(i2), c(i3){}
// Translation of triangle
Triangle translated (const Point &w) const {
Point a1 = a + w;
Point b1 = b + w;
Point c1 = c + w;
return Triangle (a1, b1, c1);
}
Triangle rotated (const double angle) {
Triangle r;
r.a = a.rotated(angle);
r.b = b.rotated(angle);
r.c = c.rotated(angle);
return r;
}
};
|