Home | History | Annotate | Download | only in Intersection
      1 /*
      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  */
      7 
      8 #if !defined QUADRATIC_UTILITIES_H
      9 #define QUADRATIC_UTILITIES_H
     10 
     11 #include "DataTypes.h"
     12 
     13 int add_valid_ts(double s[], int realRoots, double* t);
     14 void chop_at(const Quadratic& src, QuadraticPair& dst, double t);
     15 double dx_at_t(const Quadratic& , double t);
     16 double dy_at_t(const Quadratic& , double t);
     17 //void dxdy_at_t(const Quadratic& , double t, _Point& xy);
     18 _Vector dxdy_at_t(const Quadratic& , double t);
     19 
     20 double nearestT(const Quadratic& , const _Point& );
     21 bool point_in_hull(const Quadratic& , const _Point& );
     22 
     23 /* 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  */
     29 inline void set_abc(const double* quad, double& a, double& b, double& c) {
     30     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 }
     37 
     38 int quadraticRootsReal(double A, double B, double C, double t[2]);
     39 int quadraticRootsValidT(const double A, const double B, const double C, double s[2]);
     40 void sub_divide(const Quadratic& src, double t1, double t2, Quadratic& dst);
     41 _Point sub_divide(const Quadratic& src, const _Point& a, const _Point& c, double t1, double t2);
     42 void toCubic(const Quadratic& , Cubic& );
     43 _Point top(const Quadratic& , double startT, double endT);
     44 void xy_at_t(const Quadratic& , double t, double& x, double& y);
     45 _Point xy_at_t(const Quadratic& , double t);
     46 
     47 #endif
     48