Java Bezier Curve tangentCubicBezier(double t, double p0, double p1, double p2, double p3)

Here you can find the source of tangentCubicBezier(double t, double p0, double p1, double p2, double p3)

Description

This method calculates tangent of Cubic Bezier Curve.

License

Open Source License

Parameter

Parameter Description
t the value in range <0.0, 1.0>. The t in the function for a linear Bezier curve can be thought of as describing how far B(t) is from p0 to p3.
p0 the p0 Cubic Bezier Curve point.
p1 the p1 Cubic Bezier Curve point.
p2 the p2 Cubic Bezier Curve point.
p3 the p3 Cubic Bezier Curve point.

Return

the tangent of Cubic Bezier Curve

Declaration

public static double tangentCubicBezier(double t, double p0, double p1, double p2, double p3) 

Method Source Code

//package com.java2s;
/*/*from w w w . j a  v  a2 s. c om*/
 * Copyright 2012 Alex Usachev, thothbot@gmail.com
 * 
 * This file is part of Parallax project.
 * 
 * Parallax is free software: you can redistribute it and/or modify it 
 * under the terms of the Creative Commons Attribution 3.0 Unported License.
 * 
 * Parallax is distributed in the hope that it will be useful, but 
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
 * or FITNESS FOR A PARTICULAR PURPOSE. See the Creative Commons Attribution 
 * 3.0 Unported License. for more details.
 * 
 * You should have received a copy of the the Creative Commons Attribution 
 * 3.0 Unported License along with Parallax. 
 * If not, see http://creativecommons.org/licenses/by/3.0/.
 */

public class Main {
    /**
     * This method calculates tangent of Cubic Bezier Curve.
     *
     * Puay Bing, thanks for helping with this derivative!
     *
     * @param t  the value in range <0.0, 1.0>. The t in the
     *          function for a linear Bezier curve can be
     *          thought of as describing how far B(t) is from p0 to p3.
     *
     * @param p0 the p0 Cubic Bezier Curve point.
     * @param p1 the p1 Cubic Bezier Curve point.
     * @param p2 the p2 Cubic Bezier Curve point.
     * @param p3 the p3 Cubic Bezier Curve point.
     *
     * @return the tangent of Cubic Bezier Curve
     */
    public static double tangentCubicBezier(double t, double p0, double p1, double p2, double p3) {
        return -3.0 * p0 * (1.0 - t) * (1.0 - t) + 3.0 * p1 * (1.0 - t) * (1.0 - t) - 6.0 * t * p1 * (1.0 - t)
                + 6.0 * t * p2 * (1.0 - t) - 3.0 * t * t * p2 + 3.0 * t * t * p3;
    }
}