19e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com/* 29e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com * Copyright 2012 Google Inc. 39e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com * 49e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com * Use of this source code is governed by a BSD-style license that can be 59e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com * found in the LICENSE file. 69e49fb63d355446b91d20ff78ad78b297e89a50dcaryclark@google.com */ 7235f56a92f6eb6accbb243e11b3c45e3798f38f2caryclark@google.com#if !defined CUBIC_UTILITIES_H 8235f56a92f6eb6accbb243e11b3c45e3798f38f2caryclark@google.com#define CUBIC_UTILITIES_H 9235f56a92f6eb6accbb243e11b3c45e3798f38f2caryclark@google.com 108dcf114db9762c02d217beba6e29dffa4e92d298caryclark@google.com#include "DataTypes.h" 116d0032a8ec680221c2a704cac2391f2a2d77546fcaryclark@google.com#include "SkTDArray.h" 128dcf114db9762c02d217beba6e29dffa4e92d298caryclark@google.com 1373ca6243b31e225e9fd5b75a96cbc82d62557de6caryclark@google.comdouble calcPrecision(const Cubic& cubic); 14753b870c62bd22cee3d9a15efc634822724084acmtklein#ifdef SK_DEBUG 159d5f99bc309a7d733e33a149bef295ae3c8b3ac1caryclark@google.comdouble calcPrecision(const Cubic& cubic, double t, double scale); 169d5f99bc309a7d733e33a149bef295ae3c8b3ac1caryclark@google.com#endif 179d5f99bc309a7d733e33a149bef295ae3c8b3ac1caryclark@google.comvoid chop_at(const Cubic& src, CubicPair& dst, double t); 181304bb25aa3b0baa61fc2e2900fabcef88801b59caryclark@google.combool clockwise(const Cubic& c); 1927accef223a27fba437f5e825d99edbae20a045bcaryclark@google.comdouble cube_root(double x); 20d68bc309bbc3f0f4c3107cf4fa60ce1ff4847b75caryclark@google.comint cubic_to_quadratics(const Cubic& cubic, double precision, 21d68bc309bbc3f0f4c3107cf4fa60ce1ff4847b75caryclark@google.com SkTDArray<Quadratic>& quadratics); 2273ca6243b31e225e9fd5b75a96cbc82d62557de6caryclark@google.comvoid cubic_to_quadratics(const Cubic& cubic, double precision, SkTDArray<double>& ts); 23c682590538a27d73489bc91c098e000fdfb07ccfcaryclark@google.comvoid coefficients(const double* cubic, double& A, double& B, double& C, double& D); 241304bb25aa3b0baa61fc2e2900fabcef88801b59caryclark@google.combool controls_contained_by_ends(const Cubic& c); 259f60291c5375457f8adf228dbe6e8ff1186b13e1caryclark@google.comint cubicRootsValidT(double A, double B, double C, double D, double t[3]); 269f60291c5375457f8adf228dbe6e8ff1186b13e1caryclark@google.comint cubicRootsReal(double A, double B, double C, double D, double s[3]); 2773ca6243b31e225e9fd5b75a96cbc82d62557de6caryclark@google.comvoid demote_cubic_to_quad(const Cubic& cubic, Quadratic& quad); 2805c4bad470722bc4e5e6ae3d79aa8bcf9e732f06caryclark@google.comdouble dx_at_t(const Cubic& , double t); 2905c4bad470722bc4e5e6ae3d79aa8bcf9e732f06caryclark@google.comdouble dy_at_t(const Cubic& , double t); 307ff5c841bf669826b4cbd708ae1a6b3527f15dcacaryclark@google.com//void dxdy_at_t(const Cubic& , double t, _Point& y); 317ff5c841bf669826b4cbd708ae1a6b3527f15dcacaryclark@google.com_Vector dxdy_at_t(const Cubic& cubic, double t); 321304bb25aa3b0baa61fc2e2900fabcef88801b59caryclark@google.combool ends_are_extrema_in_x_or_y(const Cubic& ); 3373ca6243b31e225e9fd5b75a96cbc82d62557de6caryclark@google.comint find_cubic_inflections(const Cubic& src, double tValues[]); 341304bb25aa3b0baa61fc2e2900fabcef88801b59caryclark@google.comint find_cubic_max_curvature(const Cubic& src, double tValues[]); 351304bb25aa3b0baa61fc2e2900fabcef88801b59caryclark@google.combool monotonic_in_y(const Cubic& c); 368dcf114db9762c02d217beba6e29dffa4e92d298caryclark@google.combool rotate(const Cubic& cubic, int zero, int index, Cubic& rotPath); 371304bb25aa3b0baa61fc2e2900fabcef88801b59caryclark@google.combool serpentine(const Cubic& c); 389d5f99bc309a7d733e33a149bef295ae3c8b3ac1caryclark@google.comvoid sub_divide(const Cubic& src, double t1, double t2, Cubic& dst); 39c83c70e911a38aea03db4af8dd9841d0d77bd129caryclark@google.comvoid sub_divide(const Cubic& , const _Point& a, const _Point& d, double t1, double t2, _Point [2]); 4045a8fc6a8b00451f807783f2a6ec640e9bcc7256caryclark@google.com_Point top(const Cubic& , double startT, double endT); 418dcf114db9762c02d217beba6e29dffa4e92d298caryclark@google.comvoid xy_at_t(const Cubic& , double t, double& x, double& y); 4245a8fc6a8b00451f807783f2a6ec640e9bcc7256caryclark@google.com_Point xy_at_t(const Cubic& , double t); 43235f56a92f6eb6accbb243e11b3c45e3798f38f2caryclark@google.com 447ff5c841bf669826b4cbd708ae1a6b3527f15dcacaryclark@google.comextern const int gPrecisionUnit; 45beda389e646d6be3cfef853584a78ca8ba39d0fccaryclark@google.com 46235f56a92f6eb6accbb243e11b3c45e3798f38f2caryclark@google.com#endif 47