/** * 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 instance of <code>Curve</code>. * * @param controlPoints * see {@link #setControlPoints(List)} * @param spline * see {@link #setSpline(Spline)} */ public Curve(final List<ReadOnlyVector3> controlPoints, final Spline spline) { super(); setControlPoints(controlPoints); setSpline(spline); }
/** * 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); }
@Override protected Vector3 interpolateVectors(final ReadOnlyVector3 from, final ReadOnlyVector3 to, final double delta, final Vector3 target) { assert (null != from) : "parameter 'from' can not be null"; assert (null != to) : "parameter 'to' can not be null"; final ReadOnlyVector3 p0 = getControlPointStart(); final ReadOnlyVector3 p3 = getCotnrolPointEnd(); final Spline spline = getCurve().getSpline(); return spline.interpolate(p0, from, to, p3, delta, target); }
/** * 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); }
private boolean continueLoop(final int i, final boolean reverse) { return (reverse ? i > 0 : i < _curve.getControlPointCount() - 2); }
/** * @return The number of control points in this curve. */ public int getControlPointCount() { return getControlPoints().size(); }
/** * @see #interpolate(ReadOnlyVector3, ReadOnlyVector3, ReadOnlyVector3, ReadOnlyVector3, double, Vector3) */ public Vector3 interpolate(final ReadOnlyVector3 p0, final ReadOnlyVector3 p1, final ReadOnlyVector3 p2, final ReadOnlyVector3 p3, final double t) { return interpolate(p0, p1, p2, p3, t, new Vector3()); }
/** * 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. * @return The interpolated vector. */ public ReadOnlyVector3 interpolate(final int start, final int end, final double t) { return interpolate(start, end, t, new Vector3()); }
@Override protected int incrementIndex() { assert (null != _arcLengths) : "You need to call generateArcLengths() to create the required arc length tables!"; _distance -= _arcLengths.getLength(getIndex()); return super.incrementIndex(); }
/** * 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); }
@Override protected Vector3 interpolateVectors(final ReadOnlyVector3 from, final ReadOnlyVector3 to, final double delta, final Vector3 target) { assert (null != from) : "parameter 'from' can not be null"; assert (null != to) : "parameter 'to' can not be null"; final ReadOnlyVector3 p0 = getControlPointStart(); final ReadOnlyVector3 p3 = getCotnrolPointEnd(); final Spline spline = getCurve().getSpline(); return spline.interpolate(p0, from, to, p3, delta, target); }
/** * Creates a new instance of <code>Curve</code>. * * @param controlPoints * see {@link #setControlPoints(List)} * @param spline * see {@link #setSpline(Spline)} */ public Curve(final List<ReadOnlyVector3> controlPoints, final Spline spline) { super(); setControlPoints(controlPoints); setSpline(spline); }
/** * 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); }
private boolean continueLoop(final int i, final boolean reverse) { return (reverse ? i > 0 : i < _curve.getControlPointCount() - 2); }
/** * @return The number of control points in this curve. */ public int getControlPointCount() { return getControlPoints().size(); }
/** * @see #interpolate(ReadOnlyVector3, ReadOnlyVector3, ReadOnlyVector3, ReadOnlyVector3, double, Vector3) */ public Vector3 interpolate(final ReadOnlyVector3 p0, final ReadOnlyVector3 p1, final ReadOnlyVector3 p2, final ReadOnlyVector3 p3, final double t) { return interpolate(p0, p1, p2, p3, t, new Vector3()); }
/** * 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. * @return The interpolated vector. */ public ReadOnlyVector3 interpolate(final int start, final int end, final double t) { return interpolate(start, end, t, new Vector3()); }
@Override protected int incrementIndex() { assert (null != _arcLengths) : "You need to call generateArcLengths() to create the required arc length tables!"; _distance -= _arcLengths.getLength(getIndex()); return super.incrementIndex(); }