From 6457cd3f6e21e23e21db6dafff021d17f5457567 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Sat, 2 Jan 2021 16:31:31 +0000 Subject: asy 2.68 sources git-svn-id: svn://tug.org/texlive/trunk@57291 c570f23f-e606-0410-a88d-b1316a301751 --- Build/source/utils/asymptote/path.h | 74 ++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 37 deletions(-) (limited to 'Build/source/utils/asymptote/path.h') diff --git a/Build/source/utils/asymptote/path.h b/Build/source/utils/asymptote/path.h index 00c3a5ea3fc..107c663a11d 100644 --- a/Build/source/utils/asymptote/path.h +++ b/Build/source/utils/asymptote/path.h @@ -4,7 +4,7 @@ * * Stores a piecewise cubic spline with known control points. * - * When changing the path algorithms, also update the corresponding + * When changing the path algorithms, also update the corresponding * three-dimensional algorithms in path3.cc and three.asy. *****/ @@ -23,7 +23,7 @@ inline double Intcap(double t) { if(t >= Int_MAX) return Int_MAX; return t; } - + // The are like floor and ceil, except they return an integer; // if the argument cannot be converted to a valid integer, they return // Int_MAX (for positive arguments) or Int_MIN (for negative arguments). @@ -40,7 +40,7 @@ bool unsimpson(double integral, double (*)(double), double a, double& b, namespace camp { void checkEmpty(Int n); - + inline Int adjustedIndex(Int i, Int n, bool cycles) { checkEmpty(n); @@ -61,7 +61,7 @@ struct solvedKnot : public gc { pair post; bool straight; solvedKnot() : straight(false) {} - + friend bool operator== (const solvedKnot& p, const solvedKnot& q) { return p.pre == q.pre && p.point == q.point && p.post == q.post; @@ -74,7 +74,7 @@ extern const double Fuzz4; extern const double sqrtFuzz; extern const double BigFuzz; extern const double fuzzFactor; - + class path : public gc { bool cycles; // If the path is closed in a loop @@ -82,7 +82,7 @@ class path : public gc { mem::vector nodes; mutable double cached_length; // Cache length since path is immutable. - + mutable bbox box; mutable bbox times; // Times where minimum and maximum extents are attained. @@ -96,7 +96,7 @@ public: { nodes[0].pre = nodes[0].point = nodes[0].post = z; nodes[0].straight = false; - } + } // Creates path from a list of knots. This will be used by camp // methods such as the guide solver, but should probably not be used by a @@ -120,11 +120,11 @@ public: nodes[0].pre = nodes[0].point; nodes[1].post = nodes[1].point; } - + // Copy constructor path(const path& p) : cycles(p.cycles), n(p.n), nodes(p.nodes), cached_length(p.cached_length), - box(p.box) + box(p.box), times(p.times) {} path unstraighten() const @@ -134,7 +134,7 @@ public: P.nodes[i].straight=false; return P; } - + virtual ~path() { } @@ -159,17 +159,17 @@ public: { return cycles; } - + mem::vector& Nodes() { return nodes; } - + bool straight(Int t) const { if (cycles) return nodes[imod(t,n)].straight; return (t >= 0 && t < n) ? nodes[t].straight : false; } - + bool piecewisestraight() const { Int L=length(); @@ -177,28 +177,28 @@ public: if(!straight(i)) return false; return true; } - + pair point(Int t) const { return nodes[adjustedIndex(t,n,cycles)].point; } pair point(double t) const; - + pair precontrol(Int t) const { return nodes[adjustedIndex(t,n,cycles)].pre; } pair precontrol(double t) const; - + pair postcontrol(Int t) const { return nodes[adjustedIndex(t,n,cycles)].post; } pair postcontrol(double t) const; - + inline double norm(const pair& z0, const pair& c0, const pair& c1, const pair& z1) const { return Fuzz2*camp::max((c0-z0).abs2(), @@ -283,7 +283,7 @@ public: pair z1=point(t); return 6.0*(z1+c0)-12.0*c1; } - + pair accel(Int t, Int sign) const { if(sign == 0) return 0.5*(preaccel(t)+postaccel(t)); if(sign > 0) return postaccel(t); @@ -315,22 +315,22 @@ public: // Special case of subpath used by intersect. void halve(path &first, path &second) const; - + // Used by picture to determine bounding box. bbox bounds() const; - + pair mintimes() const { checkEmpty(n); bounds(); return camp::pair(times.left,times.bottom); } - + pair maxtimes() const { checkEmpty(n); bounds(); return camp::pair(times.right,times.top); } - + template void addpoint(bbox& box, T i) const { box.addnonempty(point(i),times,(double) i); @@ -347,15 +347,15 @@ public: // Return bounding box accounting for padding perpendicular to path. bbox bounds(double min, double max) const; - + // Return bounding box accounting for internal pen padding (but not pencap). bbox internalbounds(const bbox &padding) const; - + double cubiclength(Int i, double goal=-1) const; double arclength () const; double arctime (double l) const; double directiontime(const pair& z) const; - + pair max() const { checkEmpty(n); return bounds().Max(); @@ -365,13 +365,13 @@ public: checkEmpty(n); return bounds().Min(); } - + // Debugging output friend std::ostream& operator<< (std::ostream& out, const path& p); // Increment count if the path has a vertical component at t. bool Count(Int& count, double t) const; - + // Count if t is in (begin,end] and z lies to the left of point(i+t). void countleft(Int& count, double x, Int i, double t, double begin, double end, double& mint, double& maxt) const; @@ -382,7 +382,7 @@ public: // Transformation path transformed(const transform& t) const; - + }; double arcLength(const pair& z0, const pair& c0, const pair& c1, @@ -392,7 +392,7 @@ extern path nullpath; extern const unsigned maxdepth; extern const unsigned mindepth; extern const char *nopoints; - + bool intersect(double& S, double& T, path& p, path& q, double fuzz, unsigned depth=maxdepth); bool intersections(double& s, double& t, std::vector& S, @@ -402,27 +402,27 @@ bool intersections(double& s, double& t, std::vector& S, void intersections(std::vector& S, path& g, const pair& p, const pair& q, double fuzz); - + // Concatenates two paths into a new one. path concat(const path& p1, const path& p2); // Applies a transformation to the path path transformed(const transform& t, const path& p); - + inline double quadratic(double a, double b, double c, double x) { return a*x*x+b*x+c; } - + class quadraticroots { public: enum {NONE=0, ONE=1, TWO=2, MANY} distinct; // Number of distinct real roots. unsigned roots; // Total number of real roots. double t1,t2; // Real roots - + quadraticroots(double a, double b, double c); }; - + class Quadraticroots { public: unsigned roots; // Total number of roots. @@ -431,7 +431,7 @@ public: }; class cubicroots { -public: +public: unsigned roots; // Total number of real roots. double t1,t2,t3; cubicroots(double a, double b, double c, double d); @@ -439,13 +439,13 @@ public: path nurb(pair z0, pair z1, pair z2, pair z3, double w0, double w1, double w2, double w3, Int m); - + double orient2d(const pair& a, const pair& b, const pair& c); void roots(std::vector &roots, double a, double b, double c, double d); void roots(std::vector &r, double x0, double c0, double c1, double x1, double x); - + inline bool goodroot(double t) { return 0.0 <= t && t <= 1.0; -- cgit v1.2.3