Click or drag to resize
AB4D logo

BSpline Class

BSpline class is used to create a 3D B-spline.
Inheritance Hierarchy
SystemObject
  Ab3d.UtilitiesBSpline

Namespace: Ab3d.Utilities
Assembly: Ab3d.PowerToys (in Ab3d.PowerToys.dll) Version: 12.0.9484.2048
Syntax
C#
public class BSpline

The BSpline type exposes the following members.

Constructors
Properties
 NameDescription
Public propertyControlPoints Gets s list of control points.
Public propertyCurveDegree Gets a degree of the curve (see definition of the B-spline on the internet for more info). Default value is 3.
Public propertyWeights Gets s list of weights.
Top
Methods
 NameDescription
Public methodCreateBSpline(Int32) Returns a Point3DCollection that defines the B-spline based on the controlPoints (defined with the constructor) and positionsPerSegment. The curve positions are created using a fixed number of positions per segment. This is very fast to computer, but can generate too many points along nearly straight sections and too few where the curve bends sharply.
Public methodStatic memberCreateBSpline(IListPoint3D, Int32) Returns a Point3DCollection that defines the B-spline based on the controlPoints and positionsPerSegment. The curve positions are created using a fixed number of positions per segment. This is very fast to computer, but can generate too many points along nearly straight sections and too few where the curve bends sharply.
Public methodCreateBSpline(Double, Double, Int32) Creates the adaptive B-spline curve. The curve positions are created using an adaptive algorithm that adds more points where the curvature is higher. This takes longer to compute than when using fixed positionsPerSegment, but generates smoother curves with less positions.
Public methodStatic memberCreateBSpline(IListPoint3D, Double, Double, Int32) Returns a Point3DCollection that defines the B-spline based on the controlPoints and positionsPerSegment. The curve positions are created using an adaptive algorithm that adds more points where the curvature is higher. This takes longer to compute than when using fixed positionsPerSegment, but generates smoother curves with less positions.
Public methodCreateNURBSCurve(Int32) Returns a Point3DCollection that defines the NURBS curve based on the controlPoints and weights (defined with the constructor) and positionsPerSegment. The curve positions are created using a fixed number of positions per segment. This is very fast to computer, but can generate too many points along nearly straight sections and too few where the curve bends sharply.
Public methodCreateNURBSCurve(Double, Double, Int32) Creates the adaptive NURBS curve. The curve positions are created using an adaptive algorithm that adds more points where the curvature is higher. This takes longer to compute than when using fixed positionsPerSegment, but generates smoother curves with less positions.
Public methodStatic memberCreateNURBSCurve(IListPoint3D, IListDouble, Int32) Returns a Point3DCollection that defines the NURBS curve (Non-uniform rational B-spline) based on the controlPoints, weights and positionsPerSegment. The curve positions are created using a fixed number of positions per segment. This is very fast to computer, but can generate too many points along nearly straight sections and too few where the curve bends sharply.
Public methodStatic memberCreateNURBSCurve(IListPoint3D, IListDouble, Double, Double, Int32) Returns a Point3DCollection that defines the NURBS curve (Non-uniform rational B-spline) based on the controlPoints, weights and positionsPerSegment. The curve positions are created using an adaptive algorithm that adds more points where the curvature is higher. This takes longer to compute than when using fixed positionsPerSegment, but generates smoother curves with less positions.
Public methodGetPositionOnBSpline Returns a Point3D that lies on the B-spline based on the controlPoints (defined with the constructor) and t. The t argument can have any value from 0 to 1; 0 meaning the first control point and 1 meaning the last control point.
Public methodGetPositionOnNURBSCurve Returns a Point3D that lies on the NURBS curve based on the controlPoints and weights (defined with the constructor) and t. The t argument can have any value from 0 to 1; 0 meaning the first control point and 1 meaning the last control point.
Top
Remarks

B-spline is a curve that is defined by control points.

It is also possible to create NURBS curve (Non-uniform rational B-spline). The difference between normal B-spline and NURBS curve is that NURBS curve uses weighted control points. For example, if all the control points have weight of 1, and the 3rd control point has weight 5, the curve will go closer to the 3rd control point (making it more important). It is also possible to make the weight 0.5 - this would make the control point less important so the curve would go farther away from that control point.

B-spline does not create the curve that goes through the control points but only goes from the first to the last control points. Other control points are used to define the shape of the curve. To create a curve that goes through all control points (Bezier curve) use the BezierCurve class.

There are two ways to generate the positions:
1) Fixed positionsPerSegment number - this is very fast to compute, but can generate too many points along nearly straight sections and too few where the curve bends sharply.
2) Adaptive algorithm that adds more points where the curvature is higher - this takes longer to compute than when using fixed positionsPerSegment, but generates smoother curves with less positions.

The easiest way to create the curve is to use the static CreateBSpline(IListPoint3D, Int32) or CreateNURBSCurve(IListPoint3D, IListDouble, Int32) methods. Both methods return Point3DCollection that defines the curve.

For advanced usage it is possible to create an instance of the BSpline class. This enables calling GetPositionOnBSpline(Double) method than can return any position on the curve defined by the t parameter. The t parameter can have any value from 0 to 1; 0 meaning the first control point and 1 meaning the last control point.

See Also