Merge pull request #79 from fluddokt/omaster

More curve types #76 fix?
This commit is contained in:
Jeffrey Han 2015-04-14 00:17:02 -04:00
commit 885158d3b7
3 changed files with 8 additions and 3 deletions

View File

@ -44,9 +44,11 @@ public class CatmullCurve extends EqualDistanceMultiCurve {
LinkedList<Vec2f> points = new LinkedList<Vec2f>(); // temporary list of points to separate different curves LinkedList<Vec2f> points = new LinkedList<Vec2f>(); // temporary list of points to separate different curves
// repeat the first and last points as controls points // repeat the first and last points as controls points
// only if the first/last two points are different
// aabb // aabb
// aabc abcc // aabc abcc
// aabc abcd bcdd // aabc abcd bcdd
if (getX(0) != getX(1) || getY(0) != getY(1))
points.addLast(new Vec2f(getX(0), getY(0))); points.addLast(new Vec2f(getX(0), getY(0)));
for (int i = 0; i < ncontrolPoints; i++) { for (int i = 0; i < ncontrolPoints; i++) {
points.addLast(new Vec2f(getX(i), getY(i))); points.addLast(new Vec2f(getX(i), getY(i)));
@ -59,6 +61,8 @@ public class CatmullCurve extends EqualDistanceMultiCurve {
points.removeFirst(); points.removeFirst();
} }
} }
if (getX(ncontrolPoints - 1) != getX(ncontrolPoints - 2)
||getY(ncontrolPoints - 1) != getY(ncontrolPoints - 2))
points.addLast(new Vec2f(getX(ncontrolPoints - 1), getY(ncontrolPoints - 1))); points.addLast(new Vec2f(getX(ncontrolPoints - 1), getY(ncontrolPoints - 1)));
if (points.size() >= 4) { if (points.size() >= 4) {
try { try {

View File

@ -50,7 +50,7 @@ public abstract class CurveType {
*/ */
public void init(float approxlength) { public void init(float approxlength) {
// subdivide the curve // subdivide the curve
this.ncurve = (int) (approxlength / 4) + 1; this.ncurve = (int) (approxlength / 4) + 2;
this.curve = new Vec2f[ncurve]; this.curve = new Vec2f[ncurve];
for (int i = 0; i < ncurve; i++) for (int i = 0; i < ncurve; i++)
curve[i] = pointAt(i / (float) (ncurve - 1)); curve[i] = pointAt(i / (float) (ncurve - 1));

View File

@ -73,7 +73,7 @@ public abstract class EqualDistanceMultiCurve extends Curve {
while (distanceAt < prefDistance) { while (distanceAt < prefDistance) {
lastDistanceAt = distanceAt; lastDistanceAt = distanceAt;
lastCurve = curCurve.getCurvePoint()[curPoint]; lastCurve = curCurve.getCurvePoint()[curPoint];
distanceAt += curCurve.getCurveDistances()[curPoint++]; curPoint++;
if (curPoint >= curCurve.getCurvesCount()) { if (curPoint >= curCurve.getCurvesCount()) {
if (iter.hasNext()) { if (iter.hasNext()) {
@ -87,6 +87,7 @@ public abstract class EqualDistanceMultiCurve extends Curve {
} }
} }
} }
distanceAt += curCurve.getCurveDistances()[curPoint];
} }
Vec2f thisCurve = curCurve.getCurvePoint()[curPoint]; Vec2f thisCurve = curCurve.getCurvePoint()[curPoint];