1603c4be006d8c53905d736bf1f19a49f5ce98276Alexey Samsonov/*
2b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryany * Copyright 2012 Google Inc.
3b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryany *
4b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryany * Use of this source code is governed by a BSD-style license that can be
5b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryany * found in the LICENSE file.
6b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryany */
7b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryany#if !defined CUBIC_UTILITIES_H
8b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryany#define CUBIC_UTILITIES_H
9b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryany
10b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryany#include "DataTypes.h"
1116e0075746b21ed866ec3be21ef0d1e46f0efed5Kostya Serebryany#include "SkTDArray.h"
12b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryany
13f7667cc84cdd8923c0b6c7cfc92b7bd5692ce18cAlexey Samsonovdouble calcPrecision(const Cubic& cubic);
1416e0075746b21ed866ec3be21ef0d1e46f0efed5Kostya Serebryany#if SK_DEBUG
15b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryanydouble calcPrecision(const Cubic& cubic, double t, double scale);
16b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryany#endif
17b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryanyvoid chop_at(const Cubic& src, CubicPair& dst, double t);
18b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryanybool clockwise(const Cubic& c);
19b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryanydouble cube_root(double x);
20b3cedf98a3c8545da2234c2d35cb5d687984035fKostya Serebryanyint cubic_to_quadratics(const Cubic& cubic, double precision,
211f11d31faa5ed89b74f7d543b1182fe8de198be5Alexey Samsonov        SkTDArray<Quadratic>& quadratics);
221f11d31faa5ed89b74f7d543b1182fe8de198be5Alexey Samsonovvoid cubic_to_quadratics(const Cubic& cubic, double precision, SkTDArray<double>& ts);
231f11d31faa5ed89b74f7d543b1182fe8de198be5Alexey Samsonovvoid coefficients(const double* cubic, double& A, double& B, double& C, double& D);
241f11d31faa5ed89b74f7d543b1182fe8de198be5Alexey Samsonovbool controls_contained_by_ends(const Cubic& c);
251f11d31faa5ed89b74f7d543b1182fe8de198be5Alexey Samsonovint cubicRootsValidT(double A, double B, double C, double D, double t[3]);
261f11d31faa5ed89b74f7d543b1182fe8de198be5Alexey Samsonovint cubicRootsReal(double A, double B, double C, double D, double s[3]);
271f11d31faa5ed89b74f7d543b1182fe8de198be5Alexey Samsonovvoid demote_cubic_to_quad(const Cubic& cubic, Quadratic& quad);
281f11d31faa5ed89b74f7d543b1182fe8de198be5Alexey Samsonovdouble dx_at_t(const Cubic& , double t);
29327c1c17d9557ed8b197f732c8a070fd6ba821b5Alexey Samsonovdouble dy_at_t(const Cubic& , double t);
30327c1c17d9557ed8b197f732c8a070fd6ba821b5Alexey Samsonov//void dxdy_at_t(const Cubic& , double t, _Point& y);
31327c1c17d9557ed8b197f732c8a070fd6ba821b5Alexey Samsonov_Vector dxdy_at_t(const Cubic& cubic, double t);
32327c1c17d9557ed8b197f732c8a070fd6ba821b5Alexey Samsonovbool ends_are_extrema_in_x_or_y(const Cubic& );
33327c1c17d9557ed8b197f732c8a070fd6ba821b5Alexey Samsonovint find_cubic_inflections(const Cubic& src, double tValues[]);
34327c1c17d9557ed8b197f732c8a070fd6ba821b5Alexey Samsonovint find_cubic_max_curvature(const Cubic& src, double tValues[]);
35327c1c17d9557ed8b197f732c8a070fd6ba821b5Alexey Samsonovbool monotonic_in_y(const Cubic& c);
36327c1c17d9557ed8b197f732c8a070fd6ba821b5Alexey Samsonovbool rotate(const Cubic& cubic, int zero, int index, Cubic& rotPath);
37327c1c17d9557ed8b197f732c8a070fd6ba821b5Alexey Samsonovbool serpentine(const Cubic& c);
38f7667cc84cdd8923c0b6c7cfc92b7bd5692ce18cAlexey Samsonovvoid sub_divide(const Cubic& src, double t1, double t2, Cubic& dst);
39f7667cc84cdd8923c0b6c7cfc92b7bd5692ce18cAlexey Samsonovvoid sub_divide(const Cubic& , const _Point& a, const _Point& d, double t1, double t2, _Point [2]);
40f7667cc84cdd8923c0b6c7cfc92b7bd5692ce18cAlexey Samsonov_Point top(const Cubic& , double startT, double endT);
41f7667cc84cdd8923c0b6c7cfc92b7bd5692ce18cAlexey Samsonovvoid xy_at_t(const Cubic& , double t, double& x, double& y);
42f7667cc84cdd8923c0b6c7cfc92b7bd5692ce18cAlexey Samsonov_Point xy_at_t(const Cubic& , double t);
43f7667cc84cdd8923c0b6c7cfc92b7bd5692ce18cAlexey Samsonov
44f7667cc84cdd8923c0b6c7cfc92b7bd5692ce18cAlexey Samsonovextern const int gPrecisionUnit;
45f7667cc84cdd8923c0b6c7cfc92b7bd5692ce18cAlexey Samsonov
464fac1482179c6bfd84fa129560caa43f341c7336Alexey Samsonov#endif
474fac1482179c6bfd84fa129560caa43f341c7336Alexey Samsonov