Click or drag to resize
Ab4d.SharpEngine logo

BezierCurve Class

BezierCurve class is used to create a 3D Bezier curve.
Inheritance Hierarchy
SystemObject
  Ab4d.SharpEngine.UtilitiesBezierCurve

Namespace: Ab4d.SharpEngine.Utilities
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 2.0.8956+4c7684e186ca1be74e7a284fbe739d9a1b843d3c
Syntax
C#
public class BezierCurve

The BezierCurve type exposes the following members.

Constructors
 NameDescription
Public methodBezierCurve Creates Bezier curve with the specified array of control points. Note that each curve segment requires three control points (one for the position on the curve and two to define tangents to that position).
Top
Properties
 NameDescription
Public propertyControlPoints Array of control points.
Top
Methods
 NameDescription
Public methodStatic memberCreateBezierCurvePositions Returns an array of 3D points that define the Bezier curve with the specified control points (i.e., positions of points on the curve and tangent control points).
Public methodStatic memberCreateBezierCurvePositionsThroughPoints Returns an array of 3D points that define the Bezier curve that passes through the specified positions.
Public methodStatic memberCreateBezierCurveThroughPoints Returns an instance of BezierCurve that passes through all specified positions. The method automatically computes all required control points (tangent positions) based on the specified curve scale.
Public methodCreateCurvePositions Returns a Vector3[] array that defines the Bezier curve.
Public methodGetPositionOnCurve Returns a 3D point that lies on the Bezier curve. 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
Fields
 NameDescription
Public fieldStatic memberDefaultCurveScale Default curve scale
Top
Remarks

Bezier curve is a curve that is defined by positions of control points and the tangents at the control points. The curve passes through the specified control points, while the curvature is defined by the tangents.

The specified curve positions (the points the curve will pass though) and tangent points are defined in a single array of control points (Vector3[]).

The structure of the control points array is as follows:
control point index = 0: start position of the curve
control point index = 1: point that defines the tangent from the curve's start position to the next position.

control point index = 2: point that defines the tangent from the previous position to this position.
control point index = 3: the second position on the curve.
control point index = 4: point that defines the tangent from this position to the next position.

... (three control points for other positions; two for tangents and one for curve position.)
control point index = n - 2: point that defines the tangent from the previous position to the last position.
control point index = n - 1: the last position on the curve.

It is possible to fully define the Bezier curve by specifying all the required control points. But because it could be quite difficult to define all the tangent control points, it is also possible to define the Bezier curve by specifying only the curve positions and defining the curve scale, which defines how far from the curve positions the tangent control points are defined. This way, the curve scale defines the curvature.

The BezierCurve instance can be created by specifying all the control points in the BezierCurve constructor. To create a BezierCurve that goes through specified positions use the static CreateBezierCurvePositionsThroughPoints(Vector3, Int32, Single) static method. This method automatically calculates the tangent control positions based on the specified curveScale parameter.

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.

It is also possible to get the positions on the curve without creating an instance of BezierCurve class and with using static CreateBezierCurvePositions(Vector3, Int32) or CreateBezierCurvePositionsThroughPoints(Vector3, Int32, Single) 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 BezierCurve class. This enables calling GetPositionOnCurve(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.

NOTE: To create a B-spline or NURBS curve use the BSpline class.

See Also