Authored by Thomas Rasch

o Added RMProjectedRectUnion and RMProjectedRectIsZero to RMFoundation

... ... @@ -127,6 +127,38 @@ RMProjectedRect RMProjectedRectZero()
return RMProjectedRectMake(0.0, 0.0, 0.0, 0.0);
}
bool RMProjectedRectIsZero(RMProjectedRect rect)
{
return (rect.origin.x == 0.0) && (rect.origin.y == 0.0) && (rect.size.width == 0.0) && (rect.size.height == 0.0);
}
#if !defined (RMMIN)
#define RMMIN(a,b) ((a) < (b) ? (a) : (b))
#endif
#if !defined (RMMAX)
#define RMMAX(a,b) ((a) > (b) ? (a) : (b))
#endif
RMProjectedRect RMProjectedRectUnion(RMProjectedRect rect1, RMProjectedRect rect2)
{
bool rect1IsZero = RMProjectedRectIsZero(rect1);
bool rect2IsZero = RMProjectedRectIsZero(rect2);
if (rect1IsZero)
return (rect2IsZero ? RMProjectedRectZero() : rect2);
if (rect2IsZero)
return rect1;
double minX = RMMIN(rect1.origin.x, rect2.origin.x);
double minY = RMMIN(rect1.origin.y, rect2.origin.y);
double maxX = RMMAX(rect1.origin.x + rect1.size.width, rect2.origin.x + rect2.size.width);
double maxY = RMMAX(rect1.origin.y + rect2.size.height, rect2.origin.y + rect2.size.height);
return RMProjectedRectMake(minX, minY, maxX - minX, maxY - minY);
}
double RMEuclideanDistanceBetweenProjectedPoints(RMProjectedPoint point1, RMProjectedPoint point2)
{
double xd = point2.x - point1.x;
... ...
... ... @@ -69,16 +69,22 @@ RMProjectedRect RMTranslateProjectedRectBy(RMProjectedRect rect, RMProjectedSiz
/// \brief The function checks whether two passed projected points are equal.
bool RMProjectedPointEqualToProjectedPoint(RMProjectedPoint point1, RMProjectedPoint point2);
/// \brief The function returs true if the passed rects intersect each other.
bool RMProjectedRectIntersectsProjectedRect(RMProjectedRect rect1, RMProjectedRect rect2);
/// \brief The function returns true if rect1 contains rect2
bool RMProjectedRectContainsProjectedRect(RMProjectedRect rect1, RMProjectedRect rect2);
// Union of two rectangles
RMProjectedRect RMProjectedRectUnion(RMProjectedRect rect1, RMProjectedRect rect2);
RMProjectedPoint RMProjectedPointMake(double x, double y);
RMProjectedRect RMProjectedRectMake(double x, double y, double width, double height);
RMProjectedSize RMProjectedSizeMake(double width, double heigth);
RMProjectedRect RMProjectedRectZero();
bool RMProjectedRectIsZero(RMProjectedRect rect);
double RMEuclideanDistanceBetweenProjectedPoints(RMProjectedPoint point1, RMProjectedPoint point2);
... ...