How to work with IBezierCurve


Working with IBezierCurve

Do the following steps to work with IBezierCurve:
  1. Create an array of four points as the control points for the Bézier curve.
  2. Create a Bézier curve and define it with the four control points.
  3. Change the coordinates for some of the control points and re-define the Bézier curve.
  4. Get the degree of the Bézier curve. This should always be three.
The following code example shows how to work with some basic properties and methods of IBezierCurve:
[C#]
public void showBezierCurvesProperties()
{
    IPoint[] controlPoints = new IPoint[4];
    //Bezier FromPoint / From Tangent FromPoint. 
    controlPoints[0] = new ESRI.ArcGIS.Geometry.Point();
    //From Tangent ToPoint. 
    controlPoints[1] = new ESRI.ArcGIS.Geometry.Point();
    //To Tangent FromPoint. 
    controlPoints[2] = new ESRI.ArcGIS.Geometry.Point();
    //Bezier To Point / To Tangent ToPoint. 
    controlPoints[3] = new ESRI.ArcGIS.Geometry.Point();
    //Define the Bezier control points. This is a simple s-curve. 
    controlPoints[0].PutCoords(0, 100);
    controlPoints[1].PutCoords(100, 100);
    controlPoints[2].PutCoords(0, 0);
    controlPoints[3].PutCoords(100, 0);
    //Create the Bezier curve.
    IBezierCurveGEN bezier = new BezierCurve();
    bezier.PutCoords(ref controlPoints);
    //Get all control points from the Bezier curve. 
    bezier.QueryCoords(ref controlPoints);
    //Get each control point individually. 
    bezier.QueryCoord(0, controlPoints[0]);
    bezier.QueryCoord(1, controlPoints[1]);
    bezier.QueryCoord(2, controlPoints[2]);
    bezier.QueryCoord(3, controlPoints[3]);
    //Change the control points to define a simple CircularArc-like curve. 
    controlPoints[0].PutCoords( - 100, 200);
    controlPoints[1].PutCoords( - 100, 100);
    //Replace individual control points. 
    bezier.PutCoord(0, controlPoints[0]);
    bezier.PutCoord(1, controlPoints[1]);
    //Display the Bezier curve degree. Note: This is always three. 
    System.Windows.Forms.MessageBox.Show("Degree of Bezier: " + bezier.Degree);
}
[VB.NET]
Public Sub BezierCurves()
    Dim pBezier As IBezierCurve
    pBezier = New BezierCurve
    Dim pControlPoints(0 To 3) As IPoint
    pControlPoints(0) = New Point 'Bezier FromPoint / From Tangent FromPoint.
    pControlPoints(1) = New Point 'From Tangent ToPoint.
    pControlPoints(2) = New Point 'To Tangent FromPoint.
    pControlPoints(3) = New Point 'Bezier To Point / To Tangent ToPoint.
    'Define the Bezier control points. This is a simple s-curve.
    pControlPoints(0).PutCoords(0, 100)
    pControlPoints(1).PutCoords(100, 100)
    pControlPoints(2).PutCoords(0, 0)
    pControlPoints(3).PutCoords(100, 0)
    'Create the Bezier curve.
    pBezier.PutCoords(4, pControlPoints(0))
    'Get all of the control points from the Bezier curve.
    pBezier.QueryCoords(pControlPoints(0))
    'Get each control point individually.
    pBezier.QueryCoord(0, pControlPoints(0))
    pBezier.QueryCoord(1, pControlPoints(1))
    pBezier.QueryCoord(2, pControlPoints(2))
    pBezier.QueryCoord(3, pControlPoints(3))
    'Change the control points to define a simple CircularArc-like curve.
    pControlPoints(0).PutCoords( -100, 200)
    pControlPoints(1).PutCoords( -100, 100)
    'Replace individual control points.
    pBezier.PutCoord(0, pControlPoints(0))
    pBezier.PutCoord(1, pControlPoints(1))
    'Display the Bezier curve degree. Note: This is always three.
    MsgBox("Degree of Bezier: " & pBezier.Degree)
End Sub






To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
Development licensing Deployment licensing
ArcGIS for Desktop Basic ArcGIS for Desktop Basic
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced ArcGIS for Desktop Advanced
Engine Developer Kit Engine