blob: f3c8e64bfdf11b0463c4412155b6e8cf7f5c4089 [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.com27accef2012-01-25 18:57:23 +000018double cube_root(double x);
caryclark@google.comd68bc302013-01-07 13:17:18 +000019int cubic_to_quadratics(const Cubic& cubic, double precision,
20 SkTDArray<Quadratic>& quadratics);
caryclark@google.com73ca6242013-01-17 21:02:47 +000021void cubic_to_quadratics(const Cubic& cubic, double precision, SkTDArray<double>& ts);
caryclark@google.comc6825902012-02-03 22:07:47 +000022void coefficients(const double* cubic, double& A, double& B, double& C, double& D);
caryclark@google.com9f602912013-01-24 21:47:16 +000023int cubicRootsValidT(double A, double B, double C, double D, double t[3]);
24int cubicRootsReal(double A, double B, double C, double D, double s[3]);
caryclark@google.com73ca6242013-01-17 21:02:47 +000025void demote_cubic_to_quad(const Cubic& cubic, Quadratic& quad);
caryclark@google.com05c4bad2013-01-19 13:22:39 +000026double dx_at_t(const Cubic& , double t);
27double dy_at_t(const Cubic& , double t);
28void dxdy_at_t(const Cubic& , double t, _Point& y);
caryclark@google.com73ca6242013-01-17 21:02:47 +000029int find_cubic_inflections(const Cubic& src, double tValues[]);
caryclark@google.com8dcf1142012-07-02 20:27:02 +000030bool rotate(const Cubic& cubic, int zero, int index, Cubic& rotPath);
caryclark@google.com9d5f99b2013-01-22 12:55:54 +000031void sub_divide(const Cubic& src, double t1, double t2, Cubic& dst);
caryclark@google.com8dcf1142012-07-02 20:27:02 +000032void xy_at_t(const Cubic& , double t, double& x, double& y);
caryclark@google.com235f56a2012-09-14 14:19:30 +000033
caryclark@google.com05c4bad2013-01-19 13:22:39 +000034extern const int precisionUnit;
caryclark@google.combeda3892013-02-07 13:13:41 +000035
caryclark@google.com235f56a2012-09-14 14:19:30 +000036#endif