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(Vector3, Int32) | Returns a Vector3[] array that defines the B-spline, based on the specified control points and number of positions per segment. The curve positions are created using a fixed number of positions per segment. This is very fast to compute, but can generate too many points along nearly straight sections and too few where the curve bends sharply. | |
| CreateBSplinePositions(Vector3, Single, Single, Int32) | Returns a Vector3[] array that defines the B-spline, based on the specified control points and adaptive algorithm parameters. 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 fewer positions. | |
| CreateCurvePositions(Int32) | 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. The curve positions are created using a fixed number of positions per segment. This is very fast to compute, but can generate too many points along nearly straight sections and too few where the curve bends sharply. | |
| CreateCurvePositions(Single, Single, Int32) | Returns a Vector3[] array that defines the B-spline based on the control points (provided via the constructor) and adaptive algorithm parameters. 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 fewer positions. | |
| 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(Single, Single, Int32) | Returns a Vector3[] array that defines the NURBS curve based on the control points and weights (provided via the constructor) and adaptive algorithm parameters. 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 fewer positions. | |
| 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. | |
| CreateNURBSCurvePositions(Vector3, Single, Single, Single, Int32) | Returns a Vector3[] array that defines the NURBS curve (Non-uniform rational B-spline) based on the specified control points, weights, and adaptive algorithm parameters. 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 fewer positions. | |
| 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.
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 fewer positions.
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.