232 {
235 const double p0x = p0.fX;
236 const double p0y = p0.fY;
237 const double p2x = p2.fX;
238 const double p2y = p2.fY;
239
241
244 double hypotenuse = p0.distance(p2);
245 if (
SkTAbs(hypotenuse) < 1.0e-100) {
247 } else {
248 const double cosTheta = (p2x - p0x) / hypotenuse;
249 const double sinTheta = (p2y - p0y) / hypotenuse;
250
251
253 cosTheta, sinTheta, -(cosTheta * p0x) - (sinTheta * p0y),
254 -sinTheta, cosTheta, (sinTheta * p0x) - (cosTheta * p0y)
255 );
256 }
257 } else {
259
260
263
264 const double p1x =
fPts[1].
fX;
265 const double p1y =
fPts[1].
fY;
266
267 const double p0xSqd = p0x * p0x;
268 const double p0ySqd = p0y * p0y;
269 const double p2xSqd = p2x * p2x;
270 const double p2ySqd = p2y * p2y;
271 const double p1xSqd = p1x * p1x;
272 const double p1ySqd = p1y * p1y;
273
274 const double p01xProd = p0x * p1x;
275 const double p02xProd = p0x * p2x;
276 const double b12xProd = p1x * p2x;
277 const double p01yProd = p0y * p1y;
278 const double p02yProd = p0y * p2y;
279 const double b12yProd = p1y * p2y;
280
281
282 const double sqrtA = p0y - (2.0 * p1y) + p2y;
283 const double a = sqrtA * sqrtA;
284 const double h = -1.0 * (p0y - (2.0 * p1y) + p2y) * (p0x - (2.0 * p1x) + p2x);
285 const double sqrtB = p0x - (2.0 * p1x) + p2x;
286 const double b = sqrtB * sqrtB;
287 const double c = (p0xSqd * p2ySqd) - (4.0 * p01xProd * b12yProd)
288 - (2.0 * p02xProd * p02yProd) + (4.0 * p02xProd * p1ySqd)
289 + (4.0 * p1xSqd * p02yProd) - (4.0 * b12xProd * p01yProd)
290 + (p2xSqd * p0ySqd);
291 const double g = (p0x * p02yProd) - (2.0 * p0x * p1ySqd)
292 + (2.0 * p0x * b12yProd) - (p0x * p2ySqd)
293 + (2.0 * p1x * p01yProd) - (4.0 * p1x * p02yProd)
294 + (2.0 * p1x * b12yProd) - (p2x * p0ySqd)
295 + (2.0 * p2x * p01yProd) + (p2x * p02yProd)
296 - (2.0 * p2x * p1ySqd);
297 const double f = -((p0xSqd * p2y) - (2.0 * p01xProd * p1y)
298 - (2.0 * p01xProd * p2y) - (p02xProd * p0y)
299 + (4.0 * p02xProd * p1y) - (p02xProd * p2y)
300 + (2.0 * p1xSqd * p0y) + (2.0 * p1xSqd * p2y)
301 - (2.0 * b12xProd * p0y) - (2.0 * b12xProd * p1y)
302 + (p2xSqd * p0y));
303
304 const double cosTheta =
sqrt(
a / (
a +
b));
306
307 const double gDef = cosTheta * g - sinTheta *
f;
308 const double fDef = sinTheta * g + cosTheta *
f;
309
310
311 const double x0 = gDef / (
a +
b);
312 const double y0 = (1.0 / (2.0 * fDef)) * (c - (gDef * gDef / (
a +
b)));
313
314
315 const double lambda = -1.0 * ((
a +
b) / (2.0 * fDef));
318
319 const double lambda_cosTheta = lambda * cosTheta;
320 const double lambda_sinTheta = lambda * sinTheta;
321
322
324 lambda_cosTheta, -lambda_sinTheta, lambda * x0,
325 lambda_sinTheta, lambda_cosTheta, lambda * y0
326 );
327 }
328
331
334}
static double sign_of(const double &val)
static const double kNearlyZero
static const double kTangentTolerance
DPoint mapPoint(const SkPoint &src) const
void setAffine(double m11, double m12, double m13, double m21, double m22, double m23)
const SkPoint & endPt() const
double fTangentTolScaledSqd
DAffineMatrix fXformMatrix
static void GrowToInclude(SkRect *r, const SkPoint &pt)
SIN Vec< N, float > sqrt(const Vec< N, float > &x)
void set(const SkIRect &src)