/** * Sets the type of the spline * @param type */ public void setType(SplineType type) { this.type = type; this.computeTotalLength(); }
/** * remove the controlPoint from the spline * @param controlPoint the controlPoint to remove */ public void removeControlPoint(Vector3f controlPoint) { controlPoints.remove(controlPoint); if (controlPoints.size() > 1) { this.computeTotalLength(); } }
/** * sets the curve tension * * @param curveTension the tension */ public void setCurveTension(float curveTension) { this.curveTension = curveTension; if(type==SplineType.CatmullRom && !getControlPoints().isEmpty()) { this.computeTotalLength(); } }
/** * Create a spline * @param splineType the type of the spline @see {SplineType} * @param controlPoints a list of vector to use as control points of the spline * If the type of the curve is Bezier curve the control points should be provided * in the appropriate way. Each point 'p' describing control position in the scene * should be surrounded by two handler points. This applies to every point except * for the border points of the curve, who should have only one handle point. * The pattern should be as follows: * P0 - H0 : H1 - P1 - H1 : ... : Hn - Pn * * n is the amount of 'P' - points. * @param curveTension the tension of the spline * @param cycle true if the spline cycle. */ public Spline(SplineType splineType, List<Vector3f> controlPoints, float curveTension, boolean cycle) { if(splineType==SplineType.Nurb) { throw new IllegalArgumentException("To create NURBS spline use: 'public Spline(Vector3f[] controlPoints, float[] weights, float[] nurbKnots)' constructor!"); } type = splineType; this.controlPoints.addAll(controlPoints); this.curveTension = curveTension; this.cycle = cycle; this.computeTotalLength(); }
/** * Create a spline * @param splineType the type of the spline @see {SplineType} * @param controlPoints an array of vector to use as control points of the spline * If the type of the curve is Bezier curve the control points should be provided * in the appropriate way. Each point 'p' describing control position in the scene * should be surrounded by two handler points. This applies to every point except * for the border points of the curve, who should have only one handle point. * The pattern should be as follows: * P0 - H0 : H1 - P1 - H1 : ... : Hn - Pn * * n is the amount of 'P' - points. * @param curveTension the tension of the spline * @param cycle true if the spline cycle. */ public Spline(SplineType splineType, Vector3f[] controlPoints, float curveTension, boolean cycle) { if(splineType==SplineType.Nurb) { throw new IllegalArgumentException("To create NURBS spline use: 'public Spline(Vector3f[] controlPoints, float[] weights, float[] nurbKnots)' constructor!"); } for (int i = 0; i < controlPoints.length; i++) { Vector3f vector3f = controlPoints[i]; this.controlPoints.add(vector3f); } type = splineType; this.curveTension = curveTension; this.cycle = cycle; this.computeTotalLength(); }
/** * set to true to make the spline cycle * @param cycle */ public void setCycle(boolean cycle) { if(type!=SplineType.Nurb) { if (controlPoints.size() >= 2) { if (this.cycle && !cycle) { controlPoints.remove(controlPoints.size() - 1); } if (!this.cycle && cycle) { controlPoints.add(controlPoints.get(0)); } this.cycle = cycle; this.computeTotalLength(); } else { this.cycle = cycle; } } }
/** * Adds a controlPoint to the spline * @param controlPoint a position in world space */ public void addControlPoint(Vector3f controlPoint) { if (controlPoints.size() > 2 && this.cycle) { controlPoints.remove(controlPoints.size() - 1); } controlPoints.add(controlPoint.clone()); if (controlPoints.size() >= 2 && this.cycle) { controlPoints.add(controlPoints.get(0).clone()); } if (controlPoints.size() > 1) { this.computeTotalLength(); } }
/** * Create a NURBS spline. A spline type is automatically set to SplineType.Nurb. * The cycle is set to <b>false</b> by default. * @param controlPoints a list of vector to use as control points of the spline * @param nurbKnots the nurb's spline knots */ public Spline(List<Vector4f> controlPoints, List<Float> nurbKnots) { //input data control for(int i=0;i<nurbKnots.size()-1;++i) { if(nurbKnots.get(i)>nurbKnots.get(i+1)) { throw new IllegalArgumentException("The knots values cannot decrease!"); } } //storing the data type = SplineType.Nurb; this.weights = new float[controlPoints.size()]; this.knots = nurbKnots; this.basisFunctionDegree = nurbKnots.size() - weights.length; for(int i=0;i<controlPoints.size();++i) { Vector4f controlPoint = controlPoints.get(i); this.controlPoints.add(new Vector3f(controlPoint.x, controlPoint.y, controlPoint.z)); this.weights[i] = controlPoint.w; } CurveAndSurfaceMath.prepareNurbsKnots(knots, basisFunctionDegree); this.computeTotalLength(); }
/** * Sets the type of the spline * @param type */ public void setType(SplineType type) { this.type = type; this.computeTotalLength(); }
/** * remove the controlPoint from the spline * @param controlPoint the controlPoint to remove */ public void removeControlPoint(Vector3f controlPoint) { controlPoints.remove(controlPoint); if (controlPoints.size() > 1) { this.computeTotalLength(); } }
/** * sets the curve tension * * @param curveTension the tension */ public void setCurveTension(float curveTension) { this.curveTension = curveTension; if(type==SplineType.CatmullRom && !getControlPoints().isEmpty()) { this.computeTotalLength(); } }
/** * Create a spline * @param splineType the type of the spline @see {SplineType} * @param controlPoints a list of vector to use as control points of the spline * If the type of the curve is Bezier curve the control points should be provided * in the appropriate way. Each point 'p' describing control position in the scene * should be surrounded by two handler points. This applies to every point except * for the border points of the curve, who should have only one handle point. * The pattern should be as follows: * P0 - H0 : H1 - P1 - H1 : ... : Hn - Pn * * n is the amount of 'P' - points. * @param curveTension the tension of the spline * @param cycle true if the spline cycle. */ public Spline(SplineType splineType, List<Vector3f> controlPoints, float curveTension, boolean cycle) { if(splineType==SplineType.Nurb) { throw new IllegalArgumentException("To create NURBS spline use: 'public Spline(Vector3f[] controlPoints, float[] weights, float[] nurbKnots)' constructor!"); } type = splineType; this.controlPoints.addAll(controlPoints); this.curveTension = curveTension; this.cycle = cycle; this.computeTotalLength(); }
/** * Create a spline * @param splineType the type of the spline @see {SplineType} * @param controlPoints an array of vector to use as control points of the spline * If the type of the curve is Bezier curve the control points should be provided * in the appropriate way. Each point 'p' describing control position in the scene * should be surrounded by two handler points. This applies to every point except * for the border points of the curve, who should have only one handle point. * The pattern should be as follows: * P0 - H0 : H1 - P1 - H1 : ... : Hn - Pn * * n is the amount of 'P' - points. * @param curveTension the tension of the spline * @param cycle true if the spline cycle. */ public Spline(SplineType splineType, Vector3f[] controlPoints, float curveTension, boolean cycle) { if(splineType==SplineType.Nurb) { throw new IllegalArgumentException("To create NURBS spline use: 'public Spline(Vector3f[] controlPoints, float[] weights, float[] nurbKnots)' constructor!"); } for (int i = 0; i < controlPoints.length; i++) { Vector3f vector3f = controlPoints[i]; this.controlPoints.add(vector3f); } type = splineType; this.curveTension = curveTension; this.cycle = cycle; this.computeTotalLength(); }
/** * set to true to make the spline cycle * @param cycle */ public void setCycle(boolean cycle) { if(type!=SplineType.Nurb) { if (controlPoints.size() >= 2) { if (this.cycle && !cycle) { controlPoints.remove(controlPoints.size() - 1); } if (!this.cycle && cycle) { controlPoints.add(controlPoints.get(0)); } this.cycle = cycle; this.computeTotalLength(); } else { this.cycle = cycle; } } }
/** * Adds a controlPoint to the spline * @param controlPoint a position in world space */ public void addControlPoint(Vector3f controlPoint) { if (controlPoints.size() > 2 && this.cycle) { controlPoints.remove(controlPoints.size() - 1); } controlPoints.add(controlPoint.clone()); if (controlPoints.size() >= 2 && this.cycle) { controlPoints.add(controlPoints.get(0).clone()); } if (controlPoints.size() > 1) { this.computeTotalLength(); } }
/** * Create a NURBS spline. A spline type is automatically set to SplineType.Nurb. * The cycle is set to <b>false</b> by default. * @param controlPoints a list of vector to use as control points of the spline * @param nurbKnots the nurb's spline knots */ public Spline(List<Vector4f> controlPoints, List<Float> nurbKnots) { //input data control for(int i=0;i<nurbKnots.size()-1;++i) { if(nurbKnots.get(i)>nurbKnots.get(i+1)) { throw new IllegalArgumentException("The knots values cannot decrease!"); } } //storing the data type = SplineType.Nurb; this.weights = new float[controlPoints.size()]; this.knots = nurbKnots; this.basisFunctionDegree = nurbKnots.size() - weights.length; for(int i=0;i<controlPoints.size();++i) { Vector4f controlPoint = controlPoints.get(i); this.controlPoints.add(new Vector3f(controlPoint.x, controlPoint.y, controlPoint.z)); this.weights[i] = controlPoint.w; } CurveAndSurfaceMath.prepareNurbsKnots(knots, basisFunctionDegree); this.computeTotalLength(); }