2 * Copyright (c) 2018 Samsung Electronics Co., Ltd. All rights reserved.
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef VINTERPOLATOR_H
18 #define VINTERPOLATOR_H
27 { /* caller must call Init later */
30 VInterpolator(float aX1, float aY1, float aX2, float aY2)
32 init(aX1, aY1, aX2, aY2);
35 VInterpolator(VPointF pt1, VPointF pt2)
37 init(pt1.x(), pt1.y(), pt2.x(), pt2.y());
40 void init(float aX1, float aY1, float aX2, float aY2);
42 float value(float aX) const;
44 void GetSplineDerivativeValues(float aX, float& aDX, float& aDY) const;
47 void CalcSampleValues();
50 * Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
52 static float CalcBezier(float aT, float aA1, float aA2);
55 * Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
57 static float GetSlope(float aT, float aA1, float aA2);
59 float GetTForX(float aX) const;
61 float NewtonRaphsonIterate(float aX, float aGuessT) const;
63 float BinarySubdivide(float aX, float aA, float aB) const;
65 static float A(float aA1, float aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1; }
67 static float B(float aA1, float aA2) { return 3.0 * aA2 - 6.0 * aA1; }
69 static float C(float aA1) { return 3.0 * aA1; }
75 enum { kSplineTableSize = 11 };
76 float mSampleValues[kSplineTableSize];
77 static const float kSampleStepSize;
82 #endif // VINTERPOLATOR_H