blob: 13893a17e3c4d171ac0368c0bfcf5e5881883ca7 [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.com05c4bad2013-01-19 13:22:39 +000012double dx_at_t(const Quadratic& , double t);
13double dy_at_t(const Quadratic& , double t);
14void dxdy_at_t(const Quadratic& , double t, _Point& xy);
caryclark@google.com8dcf1142012-07-02 20:27:02 +000015
caryclark@google.com639df892012-01-10 21:46:10 +000016/* Parameterization form, given A*t*t + 2*B*t*(1-t) + C*(1-t)*(1-t)
17 *
18 * a = A - 2*B + C
19 * b = 2*B - 2*C
20 * c = C
21 */
caryclark@google.com27accef2012-01-25 18:57:23 +000022inline void set_abc(const double* quad, double& a, double& b, double& c) {
caryclark@google.com639df892012-01-10 21:46:10 +000023 a = quad[0]; // a = A
24 b = 2 * quad[2]; // b = 2*B
25 c = quad[4]; // c = C
26 b -= c; // b = 2*B - C
27 a -= b; // a = A - 2*B + C
28 b -= c; // b = 2*B - 2*C
29}
caryclark@google.com27accef2012-01-25 18:57:23 +000030
31int quadraticRoots(double A, double B, double C, double t[2]);
caryclark@google.com73ca6242013-01-17 21:02:47 +000032int quadraticRootsX(const double A, const double B, const double C, double s[2]);
caryclark@google.com8dcf1142012-07-02 20:27:02 +000033void xy_at_t(const Quadratic& , double t, double& x, double& y);
caryclark@google.com73ca6242013-01-17 21:02:47 +000034
35#endif