blob: 0fe8be837175a79ce4e9619684f3585a738578fe [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
13void chop_at(const Quadratic& src, QuadraticPair& dst, double t);
caryclark@google.com05c4bad2013-01-19 13:22:39 +000014double dx_at_t(const Quadratic& , double t);
15double dy_at_t(const Quadratic& , double t);
16void dxdy_at_t(const Quadratic& , double t, _Point& xy);
caryclark@google.com8dcf1142012-07-02 20:27:02 +000017
caryclark@google.com639df892012-01-10 21:46:10 +000018/* Parameterization form, given A*t*t + 2*B*t*(1-t) + C*(1-t)*(1-t)
19 *
20 * a = A - 2*B + C
21 * b = 2*B - 2*C
22 * c = C
23 */
caryclark@google.com27accef2012-01-25 18:57:23 +000024inline void set_abc(const double* quad, double& a, double& b, double& c) {
caryclark@google.com639df892012-01-10 21:46:10 +000025 a = quad[0]; // a = A
26 b = 2 * quad[2]; // b = 2*B
27 c = quad[4]; // c = C
28 b -= c; // b = 2*B - C
29 a -= b; // a = A - 2*B + C
30 b -= c; // b = 2*B - 2*C
31}
caryclark@google.com27accef2012-01-25 18:57:23 +000032
33int quadraticRoots(double A, double B, double C, double t[2]);
caryclark@google.com73ca6242013-01-17 21:02:47 +000034int quadraticRootsX(const double A, const double B, const double C, double s[2]);
caryclark@google.com9d5f99b2013-01-22 12:55:54 +000035void sub_divide(const Quadratic& src, double t1, double t2, Quadratic& dst);
caryclark@google.com8dcf1142012-07-02 20:27:02 +000036void xy_at_t(const Quadratic& , double t, double& x, double& y);
caryclark@google.com73ca6242013-01-17 21:02:47 +000037
38#endif