public class SplineInterpolator extends Interpolator
Basically, a cubic Bezier curve is created with start point (0,0) and endpoint (1,1). The other two control points (px1, py1) and (px2, py2) are given by the user, where px1, py1, px1, and px2 are all in the range [0,1]. A property of this specially constrained Bezier curve is that it is strictly monotonically increasing in both X and Y with t in range [0,1].
The interpolator works by giving it a value for X. It then finds what parameter t would generate this X value for the curve. Then this t parameter is applied to the curve to solve for Y. As X increases from 0 to 1, t also increases from 0 to 1, and correspondingly Y increases from 0 to 1. The X-to-Y mapping is not a function of path/curve length.
Constructor and Description |
---|
SplineInterpolator(double px1,
double py1,
double px2,
double py2)
Creates a new instance with control points (0,0) (px1,py1) (px2,py2)
(1,1) -- px1, py1, px2, py2 all in range [0,1].
|
Modifier and Type | Method and Description |
---|---|
double |
curve(double x)
Returns the y-value of the cubic bezier curve that corresponds to the x
input.
|
boolean |
equals(Object obj) |
double |
getX1() |
double |
getX2() |
double |
getY1() |
double |
getY2() |
int |
hashCode() |
String |
toString() |
interpolate, interpolate, interpolate, interpolate, interpolate, SPLINE, TANGENT, TANGENT
public SplineInterpolator(double px1, double py1, double px2, double py2)
px1
- X coordinate of first control point, in range [0,1]py1
- Y coordinate of first control point, in range [0,1]px2
- X coordinate of second control point, in range [0,1]py2
- Y coordinate of second control point, in range [0,1]public double getX1()
public double getY1()
public double getX2()
public double getY2()
public double curve(double x)
curve
in class Interpolator
x
- is x-value of cubic bezier curve, in range [0,1]Copyright © 2020. All rights reserved.