Finding a point on a Bezier curve when given the distance from the start point

来源:互联网 发布:极致软件官网 编辑:程序博客网 时间:2024/06/05 09:26

Vector vector= new Vector();for (double t = 0.00; t < 1.001; t= t + .001) {    double xValue = Math.pow((1 - t), 3) * p0.x + 3 * Math.pow((1 - t), 2) * t * p1.x + 3 * (1 - t) * Math.pow(t, 2) * p2.x + Math.pow(t, 3) * p3.x;    double yValue = Math.pow((1 - t), 3) * p0.y + 3 * Math.pow((1 - t), 2) * t * p1.y + 3 * (1 - t) * Math.pow(t, 2) * p2.y + Math.pow(t, 3) * p3.y;    v temp = new v(xValue, yValue);    vector.add(temp);}double xPos = Math.abs(Math.pow((1 - percenttraveled), 3)) * p0.x + 3 * Math.pow((1 - percenttraveled), 2) * percenttraveled * p1.x + 3 * Math.abs((1 - percenttraveled)) * Math.pow(percenttraveled, 2) * p2.x + Math.abs(Math.pow(percenttraveled, 3)) * p3.x;double yPos = Math.abs(Math.pow((1 - percenttraveled), 3)) * p0.x + 3 * Math.pow((1 - percenttraveled), 2) * percenttraveled * p1.y + 3 * Math.abs((1 - percenttraveled)) * Math.pow(percenttraveled, 2) * p2.y + Math.abs(Math.pow(percenttraveled, 3)) * p4.y;

来自:http://stackoverflow.com/questions/7801628/finding-a-point-on-a-b%c3%a9zier-curve-when-given-the-distance-from-the-start-point

http://antigrain.com/research/adaptive_bezier/#toc0003

https://github.com/libgdx/libgdx/blob/master/gdx/src/com/badlogic/gdx/math/Bezier.java

http://www.java2s.com/Code/Java/2D-Graphics-GUI/Interpolatesgivenpointsbyabeziercurve.htm

http://steve.hollasch.net/cgindex/curves/cbezarclen.html


0 0
原创粉丝点击