blob: 8ec9037e1034c6f4bbd6faeebd1d3f33c2d08b34 [file] [log] [blame]
caryclark@google.com9e49fb62012-08-27 14:11:33 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
skia.committer@gmail.com15dd3002013-01-18 07:07:28 +00007
caryclark@google.com73ca6242013-01-17 21:02:47 +00008#if !defined QUADRATIC_UTILITIES_H
9#define QUADRATIC_UTILITIES_H
10
caryclark@google.com8dcf1142012-07-02 20:27:02 +000011#include "DataTypes.h"
caryclark@google.com9d5f99b2013-01-22 12:55:54 +000012
caryclark@google.com9f602912013-01-24 21:47:16 +000013int add_valid_ts(double s[], int realRoots, double* t);
caryclark@google.com9d5f99b2013-01-22 12:55:54 +000014void chop_at(const Quadratic& src, QuadraticPair& dst, double t);
caryclark@google.com05c4bad2013-01-19 13:22:39 +000015double dx_at_t(const Quadratic& , double t);
16double dy_at_t(const Quadratic& , double t);
caryclark@google.com7ff5c842013-02-26 15:56:05 +000017//void dxdy_at_t(const Quadratic& , double t, _Point& xy);
18_Vector dxdy_at_t(const Quadratic& , double t);
19
caryclark@google.combeda3892013-02-07 13:13:41 +000020double nearestT(const Quadratic& , const _Point& );
21bool point_in_hull(const Quadratic& , const _Point& );
caryclark@google.com8dcf1142012-07-02 20:27:02 +000022
caryclark@google.com639df892012-01-10 21:46:10 +000023/* Parameterization form, given A*t*t + 2*B*t*(1-t) + C*(1-t)*(1-t)
24 *
25 * a = A - 2*B + C
26 * b = 2*B - 2*C
27 * c = C
28 */
caryclark@google.com27accef2012-01-25 18:57:23 +000029inline void set_abc(const double* quad, double& a, double& b, double& c) {
caryclark@google.com639df892012-01-10 21:46:10 +000030 a = quad[0]; // a = A
31 b = 2 * quad[2]; // b = 2*B
32 c = quad[4]; // c = C
33 b -= c; // b = 2*B - C
34 a -= b; // a = A - 2*B + C
35 b -= c; // b = 2*B - 2*C
36}
caryclark@google.com27accef2012-01-25 18:57:23 +000037
caryclark@google.com9f602912013-01-24 21:47:16 +000038int quadraticRootsReal(double A, double B, double C, double t[2]);
39int quadraticRootsValidT(const double A, const double B, const double C, double s[2]);
caryclark@google.com9d5f99b2013-01-22 12:55:54 +000040void sub_divide(const Quadratic& src, double t1, double t2, Quadratic& dst);
caryclark@google.comc83c70e2013-02-22 21:50:07 +000041_Point sub_divide(const Quadratic& src, const _Point& a, const _Point& c, double t1, double t2);
caryclark@google.comd0a19eb2013-02-19 12:49:33 +000042void toCubic(const Quadratic& , Cubic& );
caryclark@google.com45a8fc62013-02-14 15:29:11 +000043_Point top(const Quadratic& , double startT, double endT);
caryclark@google.com8dcf1142012-07-02 20:27:02 +000044void xy_at_t(const Quadratic& , double t, double& x, double& y);
caryclark@google.com47d73da2013-02-17 01:41:25 +000045_Point xy_at_t(const Quadratic& , double t);
caryclark@google.com73ca6242013-01-17 21:02:47 +000046
47#endif