71 double b,
double lambda1,
double lambda2) {
77 ep->
eta1 = atan2(sin(lambda1) / b, cos(lambda1) / a);
78 ep->
eta2 = atan2(sin(lambda2) / b, cos(lambda2) / a);
97 {3.85268, -21.229, -0.330434, 0.0127842},
98 {-1.61486, 0.706564, 0.225945, 0.263682},
99 {-0.910164, 0.388383, 0.00551445, 0.00671814},
100 {-0.630184, 0.192402, 0.0098871, 0.0102527}
103 {-0.162211, 9.94329, 0.13723, 0.0124084},
104 {-0.253135, 0.00187735, 0.0230286, 0.01264},
105 {-0.0695069, -0.0437594, 0.0120636, 0.0163087},
106 {-0.0328856, -0.00926032, -0.00173573, 0.00527385}
115 {0.0899116, -19.2349, -4.11711, 0.183362},
116 {0.138148, -1.45804, 1.32044, 1.38474},
117 {0.230903, -0.450262, 0.219963, 0.414038},
118 {0.0590565, -0.101062, 0.0430592, 0.0204699}
121 {0.0164649, 9.89394, 0.0919496, 0.00760802},
122 {0.0191603, -0.0322058, 0.0134667, -0.0825018},
123 {0.0156192, -0.017535, 0.00326508, -0.228157},
124 {-0.0236752, 0.0405821, -0.0173086, 0.176187}
131 0.001, 4.98, 0.207, 0.0067
138#define RationalFunction(x,c) ((x * (x * c[0] + c[1]) + c[2]) / (x + c[3]))
146 double c0, c1, eta = 0.5 * (etaA + etaB);
148 double x = ep->
b / ep->
a;
149 double dEta = etaB - etaA;
150 double cos2 = cos(2 * eta);
151 double cos4 = cos(4 * eta);
152 double cos6 = cos(6 * eta);
155 double (*coeffs)[4][4];
178static
void moveTo(bezier_path_t *polypath,
double x,
double y) {
179 bezier_path_append(polypath, (
pointf){.x = x, .y = y});
182static void curveTo(bezier_path_t *polypath,
double x1,
double y1,
double x2,
183 double y2,
double x3,
double y3) {
184 bezier_path_append(polypath, (
pointf){.x = x1, .y = y1});
185 bezier_path_append(polypath, (
pointf){.x = x2, .y = y2});
186 bezier_path_append(polypath, (
pointf){.x = x3, .y = y3});
189static void lineTo(bezier_path_t *polypath,
double x,
double y) {
190 const pointf curp = bezier_path_get(polypath, bezier_path_size(polypath) - 1);
191 curveTo(polypath, curp.
x, curp.
y, x, y, x, y);
195 const pointf p0 = bezier_path_get(polypath, 0);
221 static const double THRESHOLD = 0.00001;
226 while (!found && n < 1024) {
227 double diffEta = (ep->
eta2 - ep->
eta1) / n;
228 if (diffEta <= 0.5 *
M_PI) {
229 double etaOne = ep->
eta1;
231 for (i = 0; found && i < n; ++i) {
232 double etaA = etaOne;
245 aCosEtaB = ep->
a * cosEtaB;
246 bSinEtaB = ep->
b * sinEtaB;
247 aSinEtaB = ep->
a * sinEtaB;
248 bCosEtaB = ep->
b * cosEtaB;
249 xB = ep->
cx + aCosEtaB;
250 yB = ep->
cy + bSinEtaB;
254 bezier_path_t bezier_path = {0};
256 lineTo(&bezier_path, xB, yB);
259 alpha = sin(dEta) * (sqrt(4 + 3 * t * t) - 1) / 3;
261 for (i = 0; i < n; ++i) {
265 double xADot = xBDot;
266 double yADot = yBDot;
271 aCosEtaB = ep->
a * cosEtaB;
272 bSinEtaB = ep->
b * sinEtaB;
273 aSinEtaB = ep->
a * sinEtaB;
274 bCosEtaB = ep->
b * cosEtaB;
275 xB = ep->
cx + aCosEtaB;
276 yB = ep->
cy + bSinEtaB;
281 xB -
alpha * xBDot, yB -
alpha * yBDot, xB, yB);
286 polypath->
pn = bezier_path_size(&bezier_path);
287 polypath->
ps = bezier_path_detach(&bezier_path);
299 double angle0,
double angle1)
304 initEllipse(&ell, ctr.
x, ctr.
y, xsemi, ysemi, angle0, angle1);
Memory allocation wrappers that exit on failure.
static void * gv_alloc(size_t size)
static void lineTo(bezier_path_t *polypath, double x, double y)
static Ppolyline_t * genEllipticPath(ellipse_t *ep)
static erray_t coeffs3Low
static void initEllipse(ellipse_t *ep, double cx, double cy, double a, double b, double lambda1, double lambda2)
static erray_t coeffs3High
Ppolyline_t * ellipticWedge(pointf ctr, double xsemi, double ysemi, double angle0, double angle1)
static double estimateError(ellipse_t *ep, double etaA, double etaB)
static void endPath(bezier_path_t *polypath)
static void curveTo(bezier_path_t *polypath, double x1, double y1, double x2, double y2, double x3, double y3)
#define RationalFunction(x, c)
static void moveTo(bezier_path_t *polypath, double x, double y)
#define DEFINE_LIST(name, type)
finds and smooths shortest paths