Here you can find the source of findDistancedPoint(double t, Point2D sp, Point2D c1, Point2D c2, Point2D ep)
Parameter | Description |
---|---|
t | please note t varies between 0 -- 1 |
sp | starting point |
c1 | control point |
c2 | control point |
ep | end point |
public static Point2D findDistancedPoint(double t, Point2D sp, Point2D c1, Point2D c2, Point2D ep)
//package com.java2s; /*/* w w w . j a v a 2s .com*/ * =========================================== * Java Pdf Extraction Decoding Access Library * =========================================== * * Project Info: http://www.idrsolutions.com * Help section for developers at http://www.idrsolutions.com/support/ * * (C) Copyright 1997-2016 IDRsolutions and Contributors. * * This file is part of JPedal/JPDF2HTML5 * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library 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 GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * --------------- * ShadingUtils.java * --------------- */ import java.awt.geom.Point2D; public class Main { /** * method used to find any point in given distance in cubic bezier curve * * @param t please note t varies between 0 -- 1 * @param sp starting point * @param c1 control point * @param c2 control point * @param ep end point * @return */ public static Point2D findDistancedPoint(double t, Point2D sp, Point2D c1, Point2D c2, Point2D ep) { //dont use Math.pow; double d = 1 - t; double dCube = d * d * d; double dSqr = d * d; double tCube = t * t * t; double tSqr = t * t; double xCoord = (dCube * sp.getX()) + (3 * t * dSqr * c1.getX()) + (3 * tSqr * d * c2.getX()) + (tCube * ep.getX()); double yCoord = (dCube * sp.getY()) + (3 * t * dSqr * c1.getY()) + (3 * tSqr * d * c2.getY()) + (tCube * ep.getY()); return new Point2D.Double(xCoord, yCoord); } }