From 525059964fbaf380ad2c3079b965d64e7c6d06d1 Mon Sep 17 00:00:00 2001 From: randomguy3 Date: Mon, 16 Jan 2012 16:38:35 +0000 Subject: Some cleanup before calculating proper head and tail endpoints for Edge git-svn-id: https://tikzit.svn.sourceforge.net/svnroot/tikzit/trunk@379 7c02a99a-9b00-45e3-bf44-6f3dd7fddb64 --- tikzit/src/common/util.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'tikzit/src/common/util.h') diff --git a/tikzit/src/common/util.h b/tikzit/src/common/util.h index 74871dc..82ba9d8 100644 --- a/tikzit/src/common/util.h +++ b/tikzit/src/common/util.h @@ -26,6 +26,14 @@ #define M_PI 3.141592654 #endif +#ifndef MAX +#define MAX(a,b) (((a) > (b)) ? (a) : (b)) +#endif + +#ifndef MIN +#define MIN(a,b) (((a) < (b)) ? (a) : (b)) +#endif + /*! @brief Compute a bounding rectangle for two given points. @param p1 a point. @@ -85,6 +93,25 @@ float good_atan(float dx, float dy); */ float bezierInterpolate(float dist, float c0, float c1, float c2, float c3); +/*! + * @brief Find whether two line segments intersect + * @param l1start The starting point of line segment 1 + * @param l1end The ending point of line segment 1 + * @param l2start The starting point of line segment 2 + * @param l2end The ending point of line segment 2 + * @param result A location to store the intersection point + * @result YES if they intersect, NO if they do not + */ +BOOL lineSegmentsIntersect(NSPoint l1start, NSPoint l1end, NSPoint l2start, NSPoint l2end, NSPoint *result); + +/*! + * @brief Find whether a line segment enters a rectangle + * @param lineStart The starting point of the line segment + * @param lineEnd The ending point of the line segment + * @param rect The rectangle + * @result YES if they intersect, NO if they do not + */ +BOOL lineSegmentIntersectsRect(NSPoint lineStart, NSPoint lineEnd, NSRect rect); /*! @brief Round val to nearest stepSize -- cgit v1.2.3