Click or drag to resize
Ab4d.SharpEngine logo

BSpline Class

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

Namespace: Ab4d.SharpEngine.Utilities
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 1.0.8740+deb2991acfe86a95cca780cd4f82bcae2805c1a5
Syntax
C#
public class BSpline

The BSpline type exposes the following members.

Constructors
 NameDescription
Public methodBSpline(Vector3) Constructor.
Public methodBSpline(Vector3, Int32) Constructor.
Public methodBSpline(Vector3, Single) Constructor.
Public methodBSpline(Vector3, Single, Int32) Constructor.
Top
Properties
 NameDescription
Public propertyControlPoints Array of control points.
Public propertyCurveDegree Degree of the curve (see definition of the B-spline on the internet for more info). Default value is 3.
Public propertyWeights Array of weights.
Top
Methods
 NameDescription
Public methodStatic memberCreateBSplinePositions Returns a Vector3[] array that defines the B-spline, based on the specified control points and number of positions per segment.
Public methodCreateCurvePositions Returns a Vector3[] array that defines the B-spline based on the control points (provided via the constructor) and the specified number of positions per segment.
Public methodCreateNURBSCurvePositions(Int32) Returns a Vector3[] array that defines the NURBS curve based on the control points and weights (provided via the constructor) and the specified number of positions per segment.
Public methodStatic memberCreateNURBSCurvePositions(Vector3, Single, Int32) Returns a Vector3[] array that defines the NURBS curve (Non-uniform rational B-spline) based on the specified control points, weights, and number of positions per segment.
Public methodGetPositionOnBSpline Returns a 3D point that lies on the B-spline based on the control points (provided via the constructor) and t. The t argument can have any value between 0 to 1, with 0 corresponding to the first control point and 1 corresponding to the last control point.
Public methodGetPositionOnNURBSCurve Returns a 3D point that lies on the NURBS curve based on the control points and weights (provided via the constructor) and t. The t argument can have any value between 0 to 1, with 0 corresponding to the first control point and 1 corresponding to 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 the regular B-spline and the 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 of 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, which would make the control point less important and would result in the curve going farther away from that control point.

B-spline does not create a curve that passes through specified control points. It only passes through the first and the last control point, while other control points are used to define the shape of the curve. To create a curve that passes through all control points (a Bezier curve), use the BezierCurve class.

To make the curve smooth, more points are created on a segment between two control points. The number of points generated per a segment is controlled by the positionsPerSegment parameter.

The easiest way to create the curve is to use the static CreateBSplinePositions(Vector3, Int32) or CreateNURBSCurvePositions(Vector3, Single, Int32) methods. Both methods return Vector3[] array that defines the curve (i.e., the array of interpolated points that can be used to draw the curve).

For advanced use, it is possible to create an instance of the BSpline class. This enables calling GetPositionOnBSpline(Single) method that returns any position on the curve as defined by the t parameter. The t parameter can have any value between 0 to 1, with 0 corresponding to the first control point and 1 corresponding to the last control point.

See Also