2012-08-27 14:11:33 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
2013-01-18 07:07:28 +00:00
|
|
|
|
2013-01-17 21:02:47 +00:00
|
|
|
#if !defined QUADRATIC_UTILITIES_H
|
|
|
|
#define QUADRATIC_UTILITIES_H
|
|
|
|
|
2012-07-02 20:27:02 +00:00
|
|
|
#include "DataTypes.h"
|
2013-01-22 12:55:54 +00:00
|
|
|
|
2013-01-24 21:47:16 +00:00
|
|
|
int add_valid_ts(double s[], int realRoots, double* t);
|
2013-01-22 12:55:54 +00:00
|
|
|
void chop_at(const Quadratic& src, QuadraticPair& dst, double t);
|
2013-01-19 13:22:39 +00:00
|
|
|
double dx_at_t(const Quadratic& , double t);
|
|
|
|
double dy_at_t(const Quadratic& , double t);
|
2013-02-26 15:56:05 +00:00
|
|
|
//void dxdy_at_t(const Quadratic& , double t, _Point& xy);
|
|
|
|
_Vector dxdy_at_t(const Quadratic& , double t);
|
|
|
|
|
2013-02-07 13:13:41 +00:00
|
|
|
double nearestT(const Quadratic& , const _Point& );
|
|
|
|
bool point_in_hull(const Quadratic& , const _Point& );
|
2012-07-02 20:27:02 +00:00
|
|
|
|
2012-01-10 21:46:10 +00:00
|
|
|
/* Parameterization form, given A*t*t + 2*B*t*(1-t) + C*(1-t)*(1-t)
|
|
|
|
*
|
|
|
|
* a = A - 2*B + C
|
|
|
|
* b = 2*B - 2*C
|
|
|
|
* c = C
|
|
|
|
*/
|
2012-01-25 18:57:23 +00:00
|
|
|
inline void set_abc(const double* quad, double& a, double& b, double& c) {
|
2012-01-10 21:46:10 +00:00
|
|
|
a = quad[0]; // a = A
|
|
|
|
b = 2 * quad[2]; // b = 2*B
|
|
|
|
c = quad[4]; // c = C
|
|
|
|
b -= c; // b = 2*B - C
|
|
|
|
a -= b; // a = A - 2*B + C
|
|
|
|
b -= c; // b = 2*B - 2*C
|
|
|
|
}
|
2012-01-25 18:57:23 +00:00
|
|
|
|
2013-01-24 21:47:16 +00:00
|
|
|
int quadraticRootsReal(double A, double B, double C, double t[2]);
|
|
|
|
int quadraticRootsValidT(const double A, const double B, const double C, double s[2]);
|
2013-01-22 12:55:54 +00:00
|
|
|
void sub_divide(const Quadratic& src, double t1, double t2, Quadratic& dst);
|
2013-02-22 21:50:07 +00:00
|
|
|
_Point sub_divide(const Quadratic& src, const _Point& a, const _Point& c, double t1, double t2);
|
2013-02-19 12:49:33 +00:00
|
|
|
void toCubic(const Quadratic& , Cubic& );
|
2013-02-14 15:29:11 +00:00
|
|
|
_Point top(const Quadratic& , double startT, double endT);
|
2012-07-02 20:27:02 +00:00
|
|
|
void xy_at_t(const Quadratic& , double t, double& x, double& y);
|
2013-02-17 01:41:25 +00:00
|
|
|
_Point xy_at_t(const Quadratic& , double t);
|
2013-01-17 21:02:47 +00:00
|
|
|
|
|
|
|
#endif
|