Class Interpolator.BezierInterpolator

  • Enclosing class:
    Interpolator

    public static class Interpolator.BezierInterpolator
    extends Interpolator
    Bezier curve 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].

    • Constructor Detail

      • BezierInterpolator

        public BezierInterpolator​(float px1,
                                  float py1,
                                  float px2,
                                  float py2)
        constructor -- cubic bezier curve will be represented by control points (0,0) (px1,py1) (px2,py2) (1,1) -- px1, py1, px2, py2 all in range [0,1]
        Parameters:
        px1 - is x-coordinate of first control point, in range [0,1]
        py1 - is y-coordinate of first control point, in range [0,1]
        px2 - is x-coordinate of second control point, in range [0,1]
        py2 - is y-coordinate of second control point, in range [0,1]
    • Method Detail

      • getControl1

        public Point2D getControl1()
      • getControl2

        public Point2D getControl2()
      • interpolate

        public float interpolate​(float x)
        get the y-value of the cubic bezier curve that corresponds to the x input
        Specified by:
        interpolate in class Interpolator
        Parameters:
        x - is x-value of cubic bezier curve, in range [0,1]
        Returns:
        corresponding y-value of cubic bezier curve -- in range [0,1]
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object