blob: b0556191fddcc01dbdb4ce7852da51250c94bd2f [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.com235f56a2012-09-14 14:19:30 +00007#if !defined CUBIC_UTILITIES_H
8#define CUBIC_UTILITIES_H
9
caryclark@google.com8dcf1142012-07-02 20:27:02 +000010#include "DataTypes.h"
caryclark@google.com6d0032a2013-01-04 19:41:13 +000011#include "SkTDArray.h"
caryclark@google.com8dcf1142012-07-02 20:27:02 +000012
caryclark@google.com73ca6242013-01-17 21:02:47 +000013double calcPrecision(const Cubic& cubic);
caryclark@google.com9d5f99b2013-01-22 12:55:54 +000014#if SK_DEBUG
15double calcPrecision(const Cubic& cubic, double t, double scale);
16#endif
17void chop_at(const Cubic& src, CubicPair& dst, double t);
caryclark@google.com1304bb22013-03-13 20:29:41 +000018bool clockwise(const Cubic& c);
caryclark@google.com27accef2012-01-25 18:57:23 +000019double cube_root(double x);
caryclark@google.comd68bc302013-01-07 13:17:18 +000020int cubic_to_quadratics(const Cubic& cubic, double precision,
21 SkTDArray<Quadratic>& quadratics);
caryclark@google.com73ca6242013-01-17 21:02:47 +000022void cubic_to_quadratics(const Cubic& cubic, double precision, SkTDArray<double>& ts);
caryclark@google.comc6825902012-02-03 22:07:47 +000023void coefficients(const double* cubic, double& A, double& B, double& C, double& D);
caryclark@google.com1304bb22013-03-13 20:29:41 +000024bool controls_contained_by_ends(const Cubic& c);
caryclark@google.com9f602912013-01-24 21:47:16 +000025int cubicRootsValidT(double A, double B, double C, double D, double t[3]);
26int cubicRootsReal(double A, double B, double C, double D, double s[3]);
caryclark@google.com73ca6242013-01-17 21:02:47 +000027void demote_cubic_to_quad(const Cubic& cubic, Quadratic& quad);
caryclark@google.com05c4bad2013-01-19 13:22:39 +000028double dx_at_t(const Cubic& , double t);
29double dy_at_t(const Cubic& , double t);
caryclark@google.com7ff5c842013-02-26 15:56:05 +000030//void dxdy_at_t(const Cubic& , double t, _Point& y);
31_Vector dxdy_at_t(const Cubic& cubic, double t);
caryclark@google.com1304bb22013-03-13 20:29:41 +000032bool ends_are_extrema_in_x_or_y(const Cubic& );
caryclark@google.com73ca6242013-01-17 21:02:47 +000033int find_cubic_inflections(const Cubic& src, double tValues[]);
caryclark@google.com1304bb22013-03-13 20:29:41 +000034int find_cubic_max_curvature(const Cubic& src, double tValues[]);
35bool monotonic_in_y(const Cubic& c);
caryclark@google.com8dcf1142012-07-02 20:27:02 +000036bool rotate(const Cubic& cubic, int zero, int index, Cubic& rotPath);
caryclark@google.com1304bb22013-03-13 20:29:41 +000037bool serpentine(const Cubic& c);
caryclark@google.com9d5f99b2013-01-22 12:55:54 +000038void sub_divide(const Cubic& src, double t1, double t2, Cubic& dst);
caryclark@google.comc83c70e2013-02-22 21:50:07 +000039void sub_divide(const Cubic& , const _Point& a, const _Point& d, double t1, double t2, _Point [2]);
caryclark@google.com45a8fc62013-02-14 15:29:11 +000040_Point top(const Cubic& , double startT, double endT);
caryclark@google.com8dcf1142012-07-02 20:27:02 +000041void xy_at_t(const Cubic& , double t, double& x, double& y);
caryclark@google.com45a8fc62013-02-14 15:29:11 +000042_Point xy_at_t(const Cubic& , double t);
caryclark@google.com235f56a2012-09-14 14:19:30 +000043
caryclark@google.com7ff5c842013-02-26 15:56:05 +000044extern const int gPrecisionUnit;
caryclark@google.combeda3892013-02-07 13:13:41 +000045
caryclark@google.com235f56a2012-09-14 14:19:30 +000046#endif