blob: 3230e9beb57c9d88f68ff82475f41d2844dec0a0 [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 */
caryclark@google.com73ca6242013-01-17 21:02:47 +00007
8#if !defined QUADRATIC_UTILITIES_H
9#define QUADRATIC_UTILITIES_H
10
caryclark@google.com8dcf1142012-07-02 20:27:02 +000011#include "DataTypes.h"
12
13void dxdy_at_t(const Quadratic& , double t, double& x, double& y);
14
caryclark@google.com639df892012-01-10 21:46:10 +000015/* Parameterization form, given A*t*t + 2*B*t*(1-t) + C*(1-t)*(1-t)
16 *
17 * a = A - 2*B + C
18 * b = 2*B - 2*C
19 * c = C
20 */
caryclark@google.com27accef2012-01-25 18:57:23 +000021inline void set_abc(const double* quad, double& a, double& b, double& c) {
caryclark@google.com639df892012-01-10 21:46:10 +000022 a = quad[0]; // a = A
23 b = 2 * quad[2]; // b = 2*B
24 c = quad[4]; // c = C
25 b -= c; // b = 2*B - C
26 a -= b; // a = A - 2*B + C
27 b -= c; // b = 2*B - 2*C
28}
caryclark@google.com27accef2012-01-25 18:57:23 +000029
30int quadraticRoots(double A, double B, double C, double t[2]);
caryclark@google.com73ca6242013-01-17 21:02:47 +000031int quadraticRootsX(const double A, const double B, const double C, double s[2]);
caryclark@google.com8dcf1142012-07-02 20:27:02 +000032void xy_at_t(const Quadratic& , double t, double& x, double& y);
caryclark@google.com73ca6242013-01-17 21:02:47 +000033
34#endif