= 0; cosa = 0; = (long) LENGTH (x1, y1, x2, y2); = (long) LENGTH ( x2, y2, x3, y3); = (long) LENGTH (x1, y1, x3, y3); = MAX3 (a, b, c); (max == a) = (double) (b * b + c * c - a * a)/(2 * b * c); if (max == b) = (double) (c * c + a * a - b * b)/(2 * a * c); if (max == c) = (double) (b * b + a * a - c * c)/(2 * a * b); <<"ERROR!!" <
} Triangle :: draw ()
{(color); (x1, y1, x2, y2); (x2, y2, x3, y3); (x3, y3, x1, y1);
} Triangle :: operator + (Triangle & right) const
{ans = NO; (x1, y1, x2, y2, right.x1, right.y1, right.x2, right.y2)? ans = YES: ans = ans; (x1, y1, x2, y2, right.x2, right.y2, right.x3, right.y3)? ans = YES: ans = ans; (x1, y1, x2, y2, right.x1, right.y1, right.x3, right.y3)? ans = YES: ans = ans; (x2, y2, x3, y3, right.x1, right.y1, right.x2, right.y2)? ans = YES: ans = ans; (x2, y2, x3, y3, right.x2, right.y2, right.x3, right.y3)? ans = YES: ans = ans; (x2, y2, x3, y3, right.x1, right.y1, right.x3, right.y3)? ans = YES: ans = ans; (x1, y1, x3, y3, right.x1, right.y1, right.x2, right.y2)? ans = YES: ans = ans; (x1, y1, x3, y3, right.x2, right.y2, right.x3, right.y3)? ans = YES: ans = ans; (x1, y1, x3, y3, right.x1, right.y1, right.x3, right.y3)? ans = YES: ans = ans; ans;
} Triangle :: isCrossing (long x1, long y1, long x2, long y2, long a1, long b1, long a2, long b2) const
{f = YES; k1, c1, k2, c2, X; (x1 == x2) (a1 == a2) (x1 == a1) YES; NO; {= x1; = NO;
} (a1 == a2) (x1 == x2) (x1 == a1) YES; NO; {= a1; = NO;
} (f == YES) {= ((double) y2 - y1)/(x2 - x1); = ((double) x2 * y1 - x1 * y2)/(x2 - x1 ); = ((double) b2 - b1)/(a2 - a1); = ((double) a2 * b1 - a1 * b2)/(a2 - a1); (k1 == k2) (c1 == c2) YES; NO; = (c2 - c1)/(k1 - k2); ((X> = MIN (x1, x2)) && (X <= MAX (x1, x2)) && (X> = MIN (a1, a2)) && (X <= MAX (a1, a2))) YES; NO;
}. h:
# ifndef LINE_H
# define LINE_H
# include "point.h" Line: public Point {: (int a1, int b1, int a2, int b2);: x2, y2;
};
# endif.cpp:
# include "line.h" :: Line (int a1, int b1, int a2, int b2): Point (a1, b1)
{= (a2> = 0? a2: 0); = (b2> = 0? b2: 0);
}. h:
# ifndef POINT_H
# define POINT_H
# include Point {: (int a1, int b1); setColor (int col);: x1, y1, color;
};
# endif.cpp
# include "point.h" :: Point (int a1, int b1)
{= (a1> = 0? a1: 0); = (b1> = 0? b1: 0);
} Point :: setColor (int col)
{= (col> 15 | | col <0? 15: col);