private boolean continueLoop(final int i, final boolean reverse) { return (reverse ? i > 0 : i < _curve.getControlPointCount() - 2); }
private boolean continueLoop(final int i, final boolean reverse) { return (reverse ? i > 0 : i < _curve.getControlPointCount() - 2); }
/** * Creates a new <code>Line</code> from the control points making up this curve. It will have the name * <code>curve</code>, no normals, colour or texture, these can be added to the returned line if needed. * * @param steps * The number of iterations to perform between control points, the higher this number the smoother the * returned line will be, but it will also contain more vertices, must be greater than one. * @return A <code>Line</code> representing this curve, will not be <code>null</code>. */ public Line toRenderableLine(final int steps) { return toRenderableLine(1, getControlPointCount() - 2, steps); }
/** * Creates a new <code>Line</code> from the control points making up this curve. It will have the name * <code>curve</code>, no normals, colour or texture, these can be added to the returned line if needed. * * @param steps * The number of iterations to perform between control points, the higher this number the smoother the * returned line will be, but it will also contain more vertices, must be greater than one. * @return A <code>Line</code> representing this curve, will not be <code>null</code>. */ public Line toRenderableLine(final int steps) { return toRenderableLine(1, getControlPointCount() - 2, steps); }
/** * Creates a new <code>Point</code> from the control points making up this curve. It will have the name * <code>point</code>, no normals, colour or texture, these can be added to the returned point if needed. * * @param steps * The number of iterations to perform between control points, the higher this number the more points * will be shown, but it will also contain more vertices, must be greater than one. Use two to just show * the actual control points set for the curve. * @return A <code>Point</code> containing all the curve points, will not be <code>null</code>. */ public Point toRenderablePoint(final int steps) { return toRenderablePoint(1, getControlPointCount() - 2, steps); }
/** * Creates a new <code>Point</code> from the control points making up this curve. It will have the name * <code>point</code>, no normals, colour or texture, these can be added to the returned point if needed. * * @param steps * The number of iterations to perform between control points, the higher this number the more points * will be shown, but it will also contain more vertices, must be greater than one. Use two to just show * the actual control points set for the curve. * @return A <code>Point</code> containing all the curve points, will not be <code>null</code>. */ public Point toRenderablePoint(final int steps) { return toRenderablePoint(1, getControlPointCount() - 2, steps); }
/** * Calculates the length of this curve. * <p> * <strong>Important note:</strong><br /> * To calculate the length of a curve it must be interpolated (hence the steps parameter), this method will do this * EVERY time it's called (creating a lot of garbage vectors in the process). This has been done for the sake of * keeping this class simple and the code as readable as possible. Therefore the length should be manually cached * somewhere in your code if it is going to be used repeatedly. * </p> * * @param steps * The number of iterations to perform between control points, the higher this number the more accurate * the returned result will be. * @return The length of this curve. * @see #getApproximateLength(int, int, int) */ public double getApproximateLength(final int steps) { return getApproximateLength(1, getControlPointCount() - 2, steps); }
/** * Calculates the length of this curve. * <p> * <strong>Important note:</strong><br /> * To calculate the length of a curve it must be interpolated (hence the steps parameter), this method will do this * EVERY time it's called (creating a lot of garbage vectors in the process). This has been done for the sake of * keeping this class simple and the code as readable as possible. Therefore the length should be manually cached * somewhere in your code if it is going to be used repeatedly. * </p> * * @param steps * The number of iterations to perform between control points, the higher this number the more accurate * the returned result will be. * @return The length of this curve. * @see #getApproximateLength(int, int, int) */ public double getApproximateLength(final int steps) { return getApproximateLength(1, getControlPointCount() - 2, steps); }
/** * Interpolates between the control points at the given indices. * * @param start * The index of the control point to start from. * @param end * The index of the control point to end at. * @param t * Should be between zero and one. Zero will return point <code>start</code> while one will return * <code>end</code>, a value in between will return an interpolated vector between the two. * @param result * The result of the interpolation will be stored in this vector. * @return The result vector as a convenience. */ public ReadOnlyVector3 interpolate(final int start, final int end, final double t, final Vector3 result) { if (start <= 0) { throw new IllegalArgumentException("start must be > 0! start=" + start); } if (end >= (getControlPointCount() - 1)) { throw new IllegalArgumentException("end must be < " + (getControlPointCount() - 1) + "! end=" + end); } final List<ReadOnlyVector3> points = getControlPoints(); return getSpline().interpolate(points.get(start - 1), points.get(start), points.get(end), points.get(end + 1), t, result); }
/** * Interpolates between the control points at the given indices. * * @param start * The index of the control point to start from. * @param end * The index of the control point to end at. * @param t * Should be between zero and one. Zero will return point <code>start</code> while one will return * <code>end</code>, a value in between will return an interpolated vector between the two. * @param result * The result of the interpolation will be stored in this vector. * @return The result vector as a convenience. */ public ReadOnlyVector3 interpolate(final int start, final int end, final double t, final Vector3 result) { if (start <= 0) { throw new IllegalArgumentException("start must be > 0! start=" + start); } if (end >= (getControlPointCount() - 1)) { throw new IllegalArgumentException("end must be < " + (getControlPointCount() - 1) + "! end=" + end); } final List<ReadOnlyVector3> points = getControlPoints(); return getSpline().interpolate(points.get(start - 1), points.get(start), points.get(end), points.get(end + 1), t, result); }
throw new IllegalArgumentException("start must be > 0! start=" + start); if (end >= (getControlPointCount() - 1)) { throw new IllegalArgumentException("end must be < " + (getControlPointCount() - 1) + "! end=" + end);
throw new IllegalArgumentException("start must be > 0! start=" + start); if (end >= (getControlPointCount() - 1)) { throw new IllegalArgumentException("end must be < " + (getControlPointCount() - 1) + "! end=" + end);
final Vector3 previous = Vector3.fetchTempInstance(); final int loopStart = reverse ? (_curve.getControlPointCount() - 2) : 1; final double tStep = InterpolationController.DELTA_MAX / step;
final Vector3 previous = Vector3.fetchTempInstance(); final int loopStart = reverse ? (_curve.getControlPointCount() - 2) : 1; final double tStep = InterpolationController.DELTA_MAX / step;