/** * Constructor. Constructs required surface. * @param controlPoints space control points * @param nurbKnots knots of the surface * @param uSegments the amount of U segments * @param vSegments the amount of V segments * @param basisUFunctionDegree the degree of basis U function * @param basisVFunctionDegree the degree of basis V function * @param smooth defines if the mesu should be smooth (true) or flat (false) */ private Surface(List<List<Vector4f>> controlPoints, List<Float>[] nurbKnots, int uSegments, int vSegments, int basisUFunctionDegree, int basisVFunctionDegree, boolean smooth) { this.validateInputData(controlPoints, nurbKnots, uSegments, vSegments); type = SplineType.Nurb; this.uSegments = uSegments; this.vSegments = vSegments; this.controlPoints = controlPoints; knots = nurbKnots; this.basisUFunctionDegree = basisUFunctionDegree; CurveAndSurfaceMath.prepareNurbsKnots(nurbKnots[0], basisUFunctionDegree); if (nurbKnots[1] != null) { this.basisVFunctionDegree = basisVFunctionDegree; CurveAndSurfaceMath.prepareNurbsKnots(nurbKnots[1], basisVFunctionDegree); } this.buildSurface(smooth); }
/** * 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(); }
/** * Constructor. Constructs required surface. * @param controlPoints space control points * @param nurbKnots knots of the surface * @param uSegments the amount of U segments * @param vSegments the amount of V segments * @param basisUFunctionDegree the degree of basis U function * @param basisVFunctionDegree the degree of basis V function */ private Surface(List<List<Vector4f>> controlPoints, List<Float>[] nurbKnots, int uSegments, int vSegments, int basisUFunctionDegree, int basisVFunctionDegree) { this.validateInputData(controlPoints, nurbKnots, uSegments, vSegments); this.type = SplineType.Nurb; this.uSegments = uSegments; this.vSegments = vSegments; this.controlPoints = controlPoints; this.knots = nurbKnots; this.basisUFunctionDegree = basisUFunctionDegree; CurveAndSurfaceMath.prepareNurbsKnots(nurbKnots[0], basisUFunctionDegree); if (nurbKnots[1] != null) { this.basisVFunctionDegree = basisVFunctionDegree; CurveAndSurfaceMath.prepareNurbsKnots(nurbKnots[1], basisVFunctionDegree); } this.buildSurface(); }
/** * Constructor. Constructs required surface. * @param controlPoints space control points * @param nurbKnots knots of the surface * @param uSegments the amount of U segments * @param vSegments the amount of V segments * @param basisUFunctionDegree the degree of basis U function * @param basisVFunctionDegree the degree of basis V function * @param smooth defines if the mesu should be smooth (true) or flat (false) */ private Surface(List<List<Vector4f>> controlPoints, List<Float>[] nurbKnots, int uSegments, int vSegments, int basisUFunctionDegree, int basisVFunctionDegree, boolean smooth) { this.validateInputData(controlPoints, nurbKnots, uSegments, vSegments); type = SplineType.Nurb; this.uSegments = uSegments; this.vSegments = vSegments; this.controlPoints = controlPoints; knots = nurbKnots; this.basisUFunctionDegree = basisUFunctionDegree; CurveAndSurfaceMath.prepareNurbsKnots(nurbKnots[0], basisUFunctionDegree); if (nurbKnots[1] != null) { this.basisVFunctionDegree = basisVFunctionDegree; CurveAndSurfaceMath.prepareNurbsKnots(nurbKnots[1], basisVFunctionDegree); } this.buildSurface(smooth); }
/** * 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.computeTotalLentgh(); }
/** * 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(); }