summaryrefslogtreecommitdiff
path: root/tikzit/src/common/util.h
diff options
context:
space:
mode:
authorrandomguy3 <randomguy3@7c02a99a-9b00-45e3-bf44-6f3dd7fddb64>2012-01-16 16:38:35 +0000
committerrandomguy3 <randomguy3@7c02a99a-9b00-45e3-bf44-6f3dd7fddb64>2012-01-16 16:38:35 +0000
commit525059964fbaf380ad2c3079b965d64e7c6d06d1 (patch)
tree12f0dda7ee8a3d32b20ca038461287ed58c94378 /tikzit/src/common/util.h
parent69ab4ccc98cfd63cc10099de0393dc675b20b646 (diff)
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
Diffstat (limited to 'tikzit/src/common/util.h')
-rw-r--r--tikzit/src/common/util.h27
1 files changed, 27 insertions, 0 deletions
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