/// <summary> /// Initializes a new instance of <see cref="NurbsCurve" /> by it's control points and degree. /// </summary> /// <param name="controlPoints">The control points to create the curve with.</param> /// <param name="degree">The desired degree of the curve. Degree cannot be > (ControlPoints - 1)</param> public NurbsCurve(List <Point4d> controlPoints, int degree) { this.ControlPoints = controlPoints; this.Knots = NurbsCalculator.CreateUniformKnotVector(controlPoints.Count, degree) .ToList(); this.Degree = degree; }
/// <summary> /// Computes the specific amount of derivatives on the specified parameter. /// </summary> /// <param name="t">Parameter to compute derivatives at.</param> /// <param name="count">Number of derivatives to compute.</param> /// <returns>Array containing the </returns> private IList <Vector3d> DerivativesAt(double t, int count) => NurbsCalculator.NurbsCurveDerivs( this.N, this.Degree, this.Knots, this.ControlPoints, t, count );
/// <inheritdoc /> public Point3d PointAt(double u, double v) => NurbsCalculator.SurfacePoint( this.ControlPoints.N - 1, this.DegreeU, this.KnotsU, this.ControlPoints.M - 1, this.DegreeV, this.KnotsV, this.ControlPoints, u, v);
/// <summary> /// Computes the derivatives at at S(u,v). /// </summary> /// <param name="u">U parameter to compute at.</param> /// <param name="v">V parameter to compute at.</param> /// <param name="count">Number of derivatives to compute.</param> /// <returns>Computed derivatives.</returns> public Matrix <Vector3d> DerivativesAt(double u, double v, int count) => NurbsCalculator.NurbsSurfaceDerivs( this.ControlPoints.M - 1, this.DegreeU, this.KnotsU, this.ControlPoints.M - 1, this.DegreeV, this.KnotsV, this.ControlPoints, u, v, count);
/// <summary> /// Initializes a new instance of <see cref="NurbsSurface" /> by it's control points and degrees. /// </summary> /// <param name="controlPoints">Grid of control points for the surface.</param> /// <param name="degreeU">Degree of the surface in the U direction.</param> /// <param name="degreeV">Degree of the surface in the V direction.</param> public NurbsSurface(Matrix <Point4d> controlPoints, int degreeU, int degreeV) { this.ControlPoints = controlPoints; this.DegreeU = degreeU; this.DegreeV = degreeV; this.KnotsU = NurbsCalculator .CreateUniformKnotVector(this.ControlPoints.N, this.DegreeU) .ToList(); this.KnotsV = NurbsCalculator .CreateUniformKnotVector(this.ControlPoints.M, this.DegreeV) .ToList(); }
/// <inheritdoc /> public override Point3d PointAt(double t) => NurbsCalculator.CurvePoint(this.N, this.Degree, this.Knots, this.ControlPoints, t);