History

cut off quadratic curves better; don't call fabs

Sigrid Solveig Haflínudóttir committed 2 years ago

Commit 4dc78781 parent 64511ab1 file · +8 −9Browse files

Unified · Split

rast.c+8−9
@@ -58,7 +58,8 @@ struct SegQ { · 57 unmodified lines
58#define QBZR_PIX_SCALE 4.058#define QBZR_PIX_SCALE 4.0
59 59
60#define MAXCOMPONENTS 1660#define MAXCOMPONENTS 16
61#define ε 1.0e-661#define ε 1.0e-9
62#define ₀(v) ((v) > -ε && (v) < ε)
62#define min(a,b) ((a)<(b)?(a):(b))63#define min(a,b) ((a)<(b)?(a):(b))
63#define max(a,b) ((a)>(b)?(a):(b))64#define max(a,b) ((a)>(b)?(a):(b))
64 65
@@ -80,7 +81,6 @@ qslv(Sval *qs, Sval a, Sval b, Sval c) · 15 unmodified lines
80 Sval p, q, d;81 Sval p, q, d;
81 int n;82 int n;
82 83
83#define ₀(x) (x > -ε && x < ε)
84 if(₀(a)){84 if(₀(a)){
85 if(₀(b))85 if(₀(b))
86 return 0;86 return 0;
@@ -96,7 +96,6 @@ qslv(Sval *qs, Sval a, Sval b, Sval c) · 9 unmodified lines
96 qs[0] = -p;96 qs[0] = -p;
97 return qs[0] > 0 && qs[0] < 1;97 return qs[0] > 0 && qs[0] < 1;
98 }98 }
99#undef ₀
100 99
101 if(d < 0.0)100 if(d < 0.0)
102 return 0;101 return 0;
@@ -132,10 +131,10 @@ qKL(SegQ *s₀, int jj, Sval px, Sval py, Sval *K, Sval *L) · 29 unmodified lines
132 }131 }
133 132
134 /* FIXME would it make things faster to do proper convex hull test here? */133 /* FIXME would it make things faster to do proper convex hull test here? */
135 if(s.p0.x < 0 && s.p1.x < 0 && s.p2.x < 0 ||134 if(s.p0.x <= 0 && s.p1.x <= 0 && s.p2.x <= 0 ||
136 s.p0.x > 1 && s.p1.x > 1 && s.p2.x > 1 ||135 s.p0.x >= 1 && s.p1.x >= 1 && s.p2.x >= 1 ||
137 s.p0.y < 0 && s.p1.y < 0 && s.p2.y < 0 ||136 s.p0.y <= 0 && s.p1.y <= 0 && s.p2.y <= 0 ||
138 s.p0.y > 1 && s.p1.y > 1 && s.p2.y > 1)137 s.p0.y >= 1 && s.p1.y >= 1 && s.p2.y >= 1)
139 return 0;138 return 0;
140 139
141#define e(t,a) (s.p0.a*(1-t)*(1-t) + 2*s.p1.a*(1-t)*t + s.p2.a*t*t)140#define e(t,a) (s.p0.a*(1-t)*(1-t) + 2*s.p1.a*(1-t)*t + s.p2.a*t*t)
@@ -179,11 +178,11 @@ qKL(SegQ *s₀, int jj, Sval px, Sval py, Sval *K, Sval *L) · 37 unmodified lines
179 178
180 z.p0.y = e(a, y);179 z.p0.y = e(a, y);
181 z.p2.y = e(b, y);180 z.p2.y = e(b, y);
182 if(fabs(z.p0.y-1) < ε && fabs(z.p2.y-1) < ε)181 if(₀(z.p0.y) && ₀(z.p2.y))
183 continue;182 continue;
184 z.p0.x = e(a, x);183 z.p0.x = e(a, x);
185 z.p2.x = e(b, x);184 z.p2.x = e(b, x);
186 if(fabs(z.p0.x-1) < ε && fabs(z.p2.x-1) < ε)185 if(₀(z.p0.x) && ₀(z.p2.x))
187 continue;186 continue;
188#undef e187#undef e
189 188

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t