X-Git-Url: https://git.pterodactylus.net/?a=blobdiff_plain;f=synfig-core%2Ftrunk%2Fsrc%2Fsynfig%2Fcurve_helper.h;h=620387f2629d8f8a79842bf0bf728d7549bccc68;hb=9459638ad6797b8139f1e9f0715c96076dbf0890;hp=58aa696abde8c88bb3c3b6688b8c8a1b2e482a71;hpb=e8a065f2385c219c511b57dac52786120bfa097d;p=synfig.git diff --git a/synfig-core/trunk/src/synfig/curve_helper.h b/synfig-core/trunk/src/synfig/curve_helper.h index 58aa696..620387f 100644 --- a/synfig-core/trunk/src/synfig/curve_helper.h +++ b/synfig-core/trunk/src/synfig/curve_helper.h @@ -2,7 +2,7 @@ /*! \file curve_helper.h ** \brief Curve Helper Header ** -** $Id: curve_helper.h,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $ +** $Id$ ** ** \legal ** Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley @@ -43,20 +43,20 @@ namespace synfig { //line helper functions -inline Real line_point_distsq(const Point &p1, const Point &p2, +inline Real line_point_distsq(const Point &p1, const Point &p2, const Point &p, float &t) { Vector v,vt; - + v = p2 - p1; vt = p - p1; - + t = v.mag_squared() > 1e-12 ? (vt*v)/v.mag_squared() : 0; //get the projected time value for the current line - - //get distance to line segment with the time value clamped 0-1 + + //get distance to line segment with the time value clamped 0-1 if(t >= 1) //use p+v { - vt += v; //makes it pp - (p+v) + vt += v; //makes it pp - (p+v) t = 1; }else if(t > 0) //use vt-proj { @@ -65,7 +65,7 @@ inline Real line_point_distsq(const Point &p1, const Point &p2, { t = 0; } - + //else use p return vt.mag_squared(); } @@ -76,23 +76,23 @@ struct Ray { Point p; Vector v; - + Ray() {} Ray(const Point &pin, const Vector &vin):p(pin), v(vin) {} }; -/* This algorithm calculates the INTERSECTION of 2 line segments +/* This algorithm calculates the INTERSECTION of 2 line segments (not the closest point or anything like that, just intersection) //parameter values returned are [0,1] */ -int intersect(const Point &p1, const Vector &v1, float &t1, +int intersect(const Point &p1, const Vector &v1, float &t1, const Point &p2, const Vector &v2, float &t2); inline bool intersect_line_segments(const Point &a, const Point &b, float &tout, const Point &c, const Point &d, float &sout) { Vector v1(b-a), v2(d-c); - + //ok so treat both lines as parametric (so we can find the time values simultaneously) float t,s; @@ -102,11 +102,11 @@ inline bool intersect_line_segments(const Point &a, const Point &b, float &tout, sout = s; return true; } - - return false; + + return false; } -//Find the closest point on the curve to a point (and return it's distance, and time value) +//Find the closest point on the curve to a point (and return its distance, and time value) Real find_closest(const etl::bezier &curve, const Point &point, float step, Real *closest, float *t); //----------- Rectangle helper functions --------------- @@ -126,15 +126,15 @@ inline bool intersect(const etl::rect &r1, const etl::rect &r2) return (r1.minx < r2.maxx) & (r2.minx < r1.maxx) & (r1.miny < r2.maxy) & - (r2.miny < r1.maxy); + (r2.miny < r1.maxy); }*/ //----- Convex Hull of a Bezier Curve -------------- struct BezHull { - Point p[4]; + Point p[4]; int size; - + void Bound(const etl::bezier &b); }; @@ -152,7 +152,7 @@ public: struct SCurve; private: void recurse_intersect(const SCurve &left, const SCurve &right, int depth = 0); - + public: //size should be equal typedef std::vector< std::pair > intersect_set;