1 diff -Naur inkscape-1.3.2_2023-11-25_091e20ef0f/src/path/splinefit.old/splinefit.c inkscape-1.3.2_2023-11-25_091e20ef0f/src/path/splinefit/splinefit.c
2 --- inkscape-1.3.2_2023-11-25_091e20ef0f/src/path/splinefit.old/splinefit.c 2023-09-22 09:28:03.000000000 -0400
3 +++ inkscape-1.3.2_2023-11-25_091e20ef0f/src/path/splinefit/splinefit.c 2024-01-28 13:18:26.685115718 -0500
5 /* We want to find t so that spline(t) = sought */
6 /* find the value which is closest to close_to_t */
7 /* on error return closetot */
9 + spline_extended ts[3];
11 bigreal t, best, test;
15 bigreal xdiff, ydiff, sum, temp, t;
16 SplinePoint *to = spline->to, *from = spline->from;
17 - extended ts[2], x,y;
18 + spline_extended ts[2], x,y;
21 int near_vert, near_horiz;
23 *bunit.y-75*bunit.x*bunit.x*f*f*aunit.y);
24 quad.e = 80*bunit.y*(42*bunit.y*m-25*f*(bunit.y-bunit.x*f));
26 - extended solutions[4] = {-999999,-999999,-999999,-999999};
27 + spline_extended solutions[4] = {-999999,-999999,-999999,-999999};
28 _QuarticSolve(&quad,solutions);
29 - extended abSolutions[10][2]; /* there are at most 4+4+1+1=10 solutions of pairs of a and b (quartic=0,derivative=0,b=0.01,a=0.01) */
30 + spline_extended abSolutions[10][2]; /* there are at most 4+4+1+1=10 solutions of pairs of a and b (quartic=0,derivative=0,b=0.01,a=0.01) */
31 numberOfSolutions = 0;
33 + spline_extended a,b;
34 for( int i = 0; i < 4; i++ ){
36 if ( a >= 0 && a < aMax ) {
37 diff -Naur inkscape-1.3.2_2023-11-25_091e20ef0f/src/path/splinefit.old/splinefont.c inkscape-1.3.2_2023-11-25_091e20ef0f/src/path/splinefit/splinefont.c
38 --- inkscape-1.3.2_2023-11-25_091e20ef0f/src/path/splinefit.old/splinefont.c 2023-09-22 09:28:03.000000000 -0400
39 +++ inkscape-1.3.2_2023-11-25_091e20ef0f/src/path/splinefit/splinefont.c 2024-01-28 13:19:01.253342319 -0500
44 -void SplineFindExtrema(const Spline1D *sp, extended *_t1, extended *_t2 ) {
45 - extended t1= -1, t2= -1;
47 +void SplineFindExtrema(const Spline1D *sp, spline_extended *_t1, spline_extended *_t2 ) {
48 + spline_extended t1= -1, t2= -1;
49 + spline_extended b2_fourac;
51 /* Find the extreme points on the curve */
52 /* Set to -1 if there are none or if they are outside the range [0,1] */
54 /* (Does not check to see if d/dt==0 points are inflection points (rather than extrema) */
56 /* cubic, possibly 2 extrema (possibly none) */
57 - b2_fourac = 4*(extended) sp->b*sp->b - 12*(extended) sp->a*sp->c;
58 + b2_fourac = 4*(spline_extended) sp->b*sp->b - 12*(spline_extended) sp->a*sp->c;
60 b2_fourac = sqrt(b2_fourac);
61 t1 = (-2*sp->b - b2_fourac) / (6*sp->a);
62 t2 = (-2*sp->b + b2_fourac) / (6*sp->a);
63 t1 = CheckExtremaForSingleBitErrors(sp,t1,t2);
64 t2 = CheckExtremaForSingleBitErrors(sp,t2,t1);
65 - if ( t1>t2 ) { extended temp = t1; t1 = t2; t2 = temp; }
66 + if ( t1>t2 ) { spline_extended temp = t1; t1 = t2; t2 = temp; }
67 else if ( t1==t2 ) t2 = -1;
68 if ( RealNear(t1,0)) t1=0; else if ( RealNear(t1,1)) t1=1;
69 if ( RealNear(t2,0)) t2=0; else if ( RealNear(t2,1)) t2=1;
72 } else if ( sp->b!=0 ) {
73 /* Quadratic, at most one extremum */
74 - t1 = -sp->c/(2.0*(extended) sp->b);
75 + t1 = -sp->c/(2.0*(spline_extended) sp->b);
76 if ( t1<=0 || t1>=1 ) t1 = -1;
77 } else /*if ( sp->c!=0 )*/ {
78 /* linear, no extrema */
82 static int MinMaxWithin(Spline *spline) {
84 + spline_extended dx, dy;
88 + spline_extended t1, t2;
90 /* We know that this "spline" is basically one dimensional. As long as its*/
91 /* extrema are between the start and end points on that line then we can */
92 /* treat it as a line. If the extrema are way outside the line segment */
94 /* I use -999999 as an error flag, since we're really only interested in */
95 /* solns near 0 and 1 that should be ok. -1 is perhaps a little too close */
96 /* Sigh. When solutions are near 0, the rounding errors are appalling. */
97 -int _CubicSolve(const Spline1D *sp,bigreal sought, extended ts[3]) {
98 - extended d, xN, yN, delta2, temp, delta, h, t2, t3, theta;
99 - extended sa=sp->a, sb=sp->b, sc=sp->c, sd=sp->d-sought;
100 +int _CubicSolve(const Spline1D *sp,bigreal sought, spline_extended ts[3]) {
101 + spline_extended d, xN, yN, delta2, temp, delta, h, t2, t3, theta;
102 + spline_extended sa=sp->a, sb=sp->b, sc=sp->c, sd=sp->d-sought;
105 ts[0] = ts[1] = ts[2] = -999999;
106 @@ -729,24 +729,24 @@
107 /* one of the roots is 0, the other two are the soln of a quadratic */
110 - ts[1] = -sb/(extended) sa; /* two zero roots */
111 + ts[1] = -sb/(spline_extended) sa; /* two zero roots */
113 - temp = sb*(extended) sb-4*(extended) sa*sc;
114 + temp = sb*(spline_extended) sb-4*(spline_extended) sa*sc;
115 if ( RealNear(temp,0))
116 - ts[1] = -sb/(2*(extended) sa);
117 + ts[1] = -sb/(2*(spline_extended) sa);
118 else if ( temp>=0 ) {
120 - ts[1] = (-sb+temp)/(2*(extended) sa);
121 - ts[2] = (-sb-temp)/(2*(extended) sa);
122 + ts[1] = (-sb+temp)/(2*(spline_extended) sa);
123 + ts[2] = (-sb-temp)/(2*(spline_extended) sa);
126 } else if ( sa!=0 ) {
127 /* http://www.m-a.org.uk/eb/mg/mg077ch.pdf */
128 /* this nifty solution to the cubic neatly avoids complex arithmetic */
129 - xN = -sb/(3*(extended) sa);
130 + xN = -sb/(3*(spline_extended) sa);
131 yN = ((sa*xN + sb)*xN+sc)*xN + sd;
133 - delta2 = (sb*(extended) sb-3*(extended) sa*sc)/(9*(extended) sa*sa);
134 + delta2 = (sb*(spline_extended) sb-3*(spline_extended) sa*sc)/(9*(spline_extended) sa*sa);
135 /*if ( RealWithin(delta2,0,.00000001) ) delta2 = 0;*/
137 /* the descriminant is yN^2-h^2, but delta might be <0 so avoid using h */
138 @@ -782,23 +782,23 @@
139 if ( xN>=-0.0001 && xN<=1.0001 ) ts[0] = xN;
141 } else if ( sb!=0 ) {
142 - extended d = sc*(extended) sc-4*(extended) sb*sd;
143 + spline_extended d = sc*(spline_extended) sc-4*(spline_extended) sb*sd;
144 if ( d<0 && RealNear(d,0)) d=0;
146 return(false); /* All roots imaginary */
148 - ts[0] = (-sc-d)/(2*(extended) sb);
149 - ts[1] = (-sc+d)/(2*(extended) sb);
150 + ts[0] = (-sc-d)/(2*(spline_extended) sb);
151 + ts[1] = (-sc+d)/(2*(spline_extended) sb);
152 } else if ( sc!=0 ) {
153 - ts[0] = -sd/(extended) sc;
154 + ts[0] = -sd/(spline_extended) sc;
156 /* If it's a point then either everything is a solution, or nothing */
158 return( ts[0]!=-999999 );
161 -int _QuarticSolve(Quartic *q,extended ts[4]) {
162 - extended extrema[5];
163 +int _QuarticSolve(Quartic *q,spline_extended ts[4]) {
164 + spline_extended extrema[5];
166 int ecnt = 0, i, zcnt;
168 @@ -828,15 +828,15 @@
169 if ( extrema[1]!=-999999 ) {
171 if ( extrema[1]<extrema[0] ) {
172 - extended temp = extrema[1]; extrema[1] = extrema[0]; extrema[0]=temp;
173 + spline_extended temp = extrema[1]; extrema[1] = extrema[0]; extrema[0]=temp;
175 if ( extrema[2]!=-999999 ) {
177 if ( extrema[2]<extrema[0] ) {
178 - extended temp = extrema[2]; extrema[2] = extrema[0]; extrema[0]=temp;
179 + spline_extended temp = extrema[2]; extrema[2] = extrema[0]; extrema[0]=temp;
181 if ( extrema[2]<extrema[1] ) {
182 - extended temp = extrema[2]; extrema[2] = extrema[1]; extrema[1]=temp;
183 + spline_extended temp = extrema[2]; extrema[2] = extrema[1]; extrema[1]=temp;
187 @@ -849,14 +849,14 @@
189 /* divide into monotonic sections & use binary search to find zeroes */
190 for ( i=zcnt=0; i<ecnt-1; ++i ) {
191 - extended top, bottom, val;
192 - extended topt, bottomt, t;
193 + spline_extended top, bottom, val;
194 + spline_extended topt, bottomt, t;
196 bottomt = extrema[i];
197 top = (((q->a*topt+q->b)*topt+q->c)*topt+q->d)*topt+q->e;
198 bottom = (((q->a*bottomt+q->b)*bottomt+q->c)*bottomt+q->d)*bottomt+q->e;
200 - extended temp = top; top = bottom; bottom = temp;
201 + spline_extended temp = top; top = bottom; bottom = temp;
202 temp = topt; topt = bottomt; bottomt = temp;
204 if ( bottom>.001 ) /* this monotonic is all above 0 */
205 diff -Naur inkscape-1.3.2_2023-11-25_091e20ef0f/src/path/splinefit.old/splinefont.h inkscape-1.3.2_2023-11-25_091e20ef0f/src/path/splinefit/splinefont.h
206 --- inkscape-1.3.2_2023-11-25_091e20ef0f/src/path/splinefit.old/splinefont.h 2023-09-22 09:28:03.000000000 -0400
207 +++ inkscape-1.3.2_2023-11-25_091e20ef0f/src/path/splinefit/splinefont.h 2024-01-28 13:19:19.188368504 -0500
211 typedef double bigreal;
212 -typedef double extended;
213 +typedef double spline_extended;
216 #define chunkalloc(size) calloc(1,size)
218 void SplineRefigure3(Spline *spline);
219 void SplineRefigure(Spline *spline);
220 int SplineIsLinear(Spline *spline);
221 -void SplineFindExtrema(const Spline1D *sp, extended *_t1, extended *_t2 );
222 +void SplineFindExtrema(const Spline1D *sp, spline_extended *_t1, spline_extended *_t2 );
223 bigreal SplineMinDistanceToPoint(Spline *s, BasePoint *p);
225 void SplinePointFree(SplinePoint *sp);
227 bigreal BPCross(BasePoint v1, BasePoint v2);
228 BasePoint BPRev(BasePoint v);
230 -int _CubicSolve(const Spline1D *sp,bigreal sought, extended ts[3]);
231 -int _QuarticSolve(Quartic *q,extended ts[4]);
232 +int _CubicSolve(const Spline1D *sp,bigreal sought, spline_extended ts[3]);
233 +int _QuarticSolve(Quartic *q,spline_extended ts[4]);
234 int IntersectLines(BasePoint *inter,
235 BasePoint *line1_1, BasePoint *line1_2,
236 BasePoint *line2_1, BasePoint *line2_2);