MCPcopy Create free account
hub / github.com/SuperMap/iClient-JavaScript / processArc

Function processArc

libs/echarts/echarts.simple.js:15196–15246  ·  view source on GitHub ↗
(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path)

Source from the content-addressed store, hash-verified

15194};
15195
15196function processArc(x1, y1, x2, y2, fa, fs, rx, ry, psiDeg, cmd, path) {
15197 var psi = psiDeg * (PI / 180.0);
15198 var xp = mathCos(psi) * (x1 - x2) / 2.0
15199 + mathSin(psi) * (y1 - y2) / 2.0;
15200 var yp = -1 * mathSin(psi) * (x1 - x2) / 2.0
15201 + mathCos(psi) * (y1 - y2) / 2.0;
15202
15203 var lambda = (xp * xp) / (rx * rx) + (yp * yp) / (ry * ry);
15204
15205 if (lambda > 1) {
15206 rx *= mathSqrt(lambda);
15207 ry *= mathSqrt(lambda);
15208 }
15209
15210 var f = (fa === fs ? -1 : 1)
15211 * mathSqrt((((rx * rx) * (ry * ry))
15212 - ((rx * rx) * (yp * yp))
15213 - ((ry * ry) * (xp * xp))) / ((rx * rx) * (yp * yp)
15214 + (ry * ry) * (xp * xp))
15215 ) || 0;
15216
15217 var cxp = f * rx * yp / ry;
15218 var cyp = f * -ry * xp / rx;
15219
15220 var cx = (x1 + x2) / 2.0
15221 + mathCos(psi) * cxp
15222 - mathSin(psi) * cyp;
15223 var cy = (y1 + y2) / 2.0
15224 + mathSin(psi) * cxp
15225 + mathCos(psi) * cyp;
15226
15227 var theta = vAngle([ 1, 0 ], [ (xp - cxp) / rx, (yp - cyp) / ry ]);
15228 var u = [ (xp - cxp) / rx, (yp - cyp) / ry ];
15229 var v = [ (-1 * xp - cxp) / rx, (-1 * yp - cyp) / ry ];
15230 var dTheta = vAngle(u, v);
15231
15232 if (vRatio(u, v) <= -1) {
15233 dTheta = PI;
15234 }
15235 if (vRatio(u, v) >= 1) {
15236 dTheta = 0;
15237 }
15238 if (fs === 0 && dTheta > 0) {
15239 dTheta = dTheta - 2 * PI;
15240 }
15241 if (fs === 1 && dTheta < 0) {
15242 dTheta = dTheta + 2 * PI;
15243 }
15244
15245 path.addData(cmd, cx, cy, rx, ry, theta, dTheta, psi, fs);
15246}
15247
15248
15249var commandReg = /([mlvhzcqtsa])([^mlvhzcqtsa]*)/ig;

Callers 1

Calls 3

vAngleFunction · 0.70
vRatioFunction · 0.70
addDataMethod · 0.45

Tested by

no test coverage detected