BSpline Class |
public class BSpline
The BSpline type exposes the following members.
Name | Description | |
---|---|---|
BSpline(Vector3) | Constructor. | |
BSpline(Vector3, Int32) | Constructor. | |
BSpline(Vector3, Single) | Constructor. | |
BSpline(Vector3, Single, Int32) | Constructor. |
Name | Description | |
---|---|---|
ControlPoints | Array of control points. | |
CurveDegree | Degree of the curve (see definition of the B-spline on the internet for more info). Default value is 3. | |
Weights | Array of weights. |
Name | Description | |
---|---|---|
CreateBSplinePositions | Returns a Vector3[] array that defines the B-spline, based on the specified control points and number of positions per segment. | |
CreateCurvePositions | 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. | |
CreateNURBSCurvePositions(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. | |
CreateNURBSCurvePositions(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. | |
GetPositionOnBSpline | 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. | |
GetPositionOnNURBSCurve | 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. |
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.