Using some basic properties and methods on ICircularArc
Do the following steps to use properties and methods on ICircularArc:
- Define the center point of the circle.
- Define a quarter circle (Pi/2 radians) from Pi/3 (60 degrees) to 5*Pi/6 (150 degrees) in a counterclockwise direction with a radius of 100 and a center at (0,0).
- Set circularArc equal to the complement circular arc, which can be defined by circularArc.PutCoordsByAngle(origin, Pi/3, -3*Pi/2, 100).
- Query the center, start, and end points as well as orientation. These are the points required by PutCoords, but the ArcOrientation still needs to be checked against special cases.
- Set orientation to the IsCCW value unless the start and end Points are the same.
- Recreate the CircularArc using PutCoords.
- Construct the same arc using ConstructThreePoints.
- Change the radius so that the new radius is the distance between the origin and the new point. Basically, it places the arc on the embedded circle with the same center point and the new input point.
- Query some of the properties of the arc.
The following code example shows how to work with some basic properties and methods of ICircularArc:
[C#] public void DemonstrateCircularArcs()
{
IPoint origin=new ESRI.ArcGIS.Geometry.Point();
origin.PutCoords(0, 0);
ICircularArc circularArc=new CircularArcClass();
circularArc.PutCoordsByAngle(origin, Math.PI / 3, Math.PI / 2, 100);
OutputArcProperties(circularArc);
circularArc.Complement();
OutputArcProperties(circularArc);
IPoint startPoint=new ESRI.ArcGIS.Geometry.Point();
IPoint endPoint=new ESRI.ArcGIS.Geometry.Point();
bool isCCW=false;
bool isMinor=false;
circularArc.QueryCoords(origin, startPoint, endPoint, ref isCCW, ref isMinor);
//Set orientation to the IsCCW value unless start and end points are the same.
esriArcOrientation arcOrientation=0;
if ((circularArc.IsClosed) || (circularArc.Length < (Math.Pow(10, - 12))))
{
if (isMinor)
{
arcOrientation=esriArcOrientation.esriArcMinor;
}
else
{
arcOrientation=esriArcOrientation.esriArcMajor;
}
if (isCCW)
{
arcOrientation=esriArcOrientation.esriArcCounterClockwise;
}
else
{
arcOrientation=esriArcOrientation.esriArcClockwise;
}
}
//Note: The start and end points must be the same distance (the radius)
// from the center point. Otherwise, an empty geometry is created.
circularArc.PutCoords(origin, startPoint, endPoint, arcOrientation);
OutputArcProperties(circularArc);
IPoint throughPoint=new ESRI.ArcGIS.Geometry.Point();
//This is a point on the arc.
throughPoint.PutCoords(0, - 100);
//Changes the radius so that the new radius is the distance between the origin and the new point.
IConstructCircularArc threePointArcConstruction=new CircularArcClass();
threePointArcConstruction.ConstructThreePoints(startPoint, throughPoint,
endPoint, false);
ICircularArc threePointArc=threePointArcConstruction as ICircularArc;
OutputArcProperties(threePointArc);
//Query only the center point into origin.
threePointArc.QueryCenterPoint(origin);
throughPoint.PutCoords(0, 150);
threePointArc.PutRadiusByPoint(throughPoint);
//Query the center point, from angle, central angle, and radius.
//This is the same information needed to use PutCoordsByAngle.
double angelFromArc=0;
double centerAngel=0;
double radius=0;
threePointArc.QueryCoordsByAngle(origin, ref angelFromArc, ref centerAngel, ref
radius);
OutputArcProperties(threePointArc);
}
private void OutputArcProperties(ICircularArc circularArc)
{
String report="Center Point: (" + circularArc.CenterPoint.X + ", " +
circularArc.CenterPoint.Y + ")" + "\n" + "From Point: (" +
circularArc.FromPoint.X + ", " + circularArc.FromPoint.Y + ")" + "\n" +
"To Point: (" + circularArc.ToPoint.X + ", " + circularArc.ToPoint.Y + ")" +
"\n" + "From Angle: " + circularArc.FromAngle + "\n" + "Central Angle: " +
circularArc.CentralAngle + "\n" + "To Angle: " + circularArc.ToAngle + "\n"
+ "Radius: " + circularArc.Radius + "\n" + "Chord Height: " +
circularArc.ChordHeight + "\n" + "IsCounterClockwise: " +
circularArc.IsCounterClockwise + "\n" + "IsMinor: " + circularArc.IsMinor +
"\n" + "IsLine: " + circularArc.IsLine + "\n" + "IsPoint: " +
circularArc.IsPoint + ")";
//IsLine and IsPoint check for degenerate cases of CircularArcs.
System.Windows.Forms.MessageBox.Show(report);
}
[VB.NET] Public Sub DemonstrateCircularArcs()
Dim pCArc As ICircularArc
pCArc=New CircularArc
Dim pOrigin As IPoint
pOrigin=New Point
Dim Pi As Double
Dim pStartPoint As IPoint
Dim pEndPoint As IPoint
pStartPoint=New Point
pEndPoint=New Point
Dim bIsCCW As Boolean
Dim bIsMinor As Boolean
Dim CArcFromAngle As Double
Dim CArcCenterAngle As Double
Dim CArcRadius As Double
Dim CArcOrientation As esriArcOrientation
Dim pConstCArc2 As IConstructCircularArc
Dim pCArc2 As ICircularArc
Dim pThroughPoint As IPoint
pCArc2=New CircularArc
pThroughPoint=New Point
pConstCArc2=pCArc2
'This defines the constant Pi=3.14159265358979.
Pi=4 * Math.Atan(1)
'Define the center point of the circle.
pOrigin.PutCoords(0, 0)
'Define a quarter circle (Pi/2 radians) from Pi/3 (60 degress)
' to 5*Pi/6 (150 degrees) in a counterclockwise direction
' with a radius of 100 and a center at (0,0).
pCArc.PutCoordsByAngle(pOrigin, Pi / 3, Pi / 2, 100)
OutputCArcProperties(pCArc)
'Set pCArc equal to the complement circular arc,
'which could be defined by pCArc.PutCoordsByAngle pOrigin, Pi/3, -3*Pi/2, 100.
pCArc.Complement()
OutputCArcProperties(pCArc)
'Query the center, start, and end points as well as orientation.
'These are the points required by PutCoords, but the ArcOrientation
' still needs to be checked against special cases.
pCArc.QueryCoords(pOrigin, pStartPoint, pEndPoint, bIsCCW, bIsMinor)
'Set orientation to the IsCCW value unless start and end points are the same.
If (pCArc.IsClosed) Or (pCArc.Length < (10 ^ -12)) Then
If bIsMinor Then
CArcOrientation=esriArcOrientation.esriArcMinor
Else
CArcOrientation=esriArcOrientation.esriArcMajor
End If
Else
If bIsCCW Then
CArcOrientation=esriArcOrientation.esriArcCounterClockwise
Else
CArcOrientation=esriArcOrientation.esriArcClockwise
End If
End If
'Recreate the CircularArc using PutCoords.
'Note: The start and end points must be the same distance (the radius)
' from the center point. Otherwise, an empty geometry is created.
pCArc.PutCoords(pOrigin, pStartPoint, pEndPoint, CArcOrientation)
OutputCArcProperties(pCArc)
'Now you will construct the same arc using ConstructThreePoints.
pThroughPoint.PutCoords(0, -100) 'This is a point on the arc.
pConstCArc2.ConstructThreePoints(pStartPoint, pThroughPoint, pEndPoint, False)
OutputCArcProperties(pCArc2)
'Query only the center point into pOrigin.
pCArc2.QueryCenterPoint(pOrigin)
pThroughPoint.PutCoords(0, 150)
'Change the radius so that the new radius is the distance between the origin
' and the new point. Basically, it places the arc on the embedded circle
' with the same center point and the new input point.
pCArc2.PutRadiusByPoint(pThroughPoint)
'Query the center point, from angle, central angle, and radius.
'This is the same information needed to use PutCoordsByAngle.
pCArc2.QueryCoordsByAngle(pOrigin, CArcFromAngle, CArcCenterAngle, CArcRadius)
OutputCArcProperties(pCArc2)
End Sub
Private Sub OutputCArcProperties(ByVal pInCArc As ICircularArc)
MsgBox("Center Point: (" & pInCArc.CenterPoint.X & ", " & _
pInCArc.CenterPoint.Y & ")" & vbCrLf & _
"From Point: (" & pInCArc.FromPoint.X & ", " & _
pInCArc.FromPoint.Y & ")" & vbCrLf & _
"To Point: (" & pInCArc.ToPoint.X & ", " & _
pInCArc.ToPoint.Y & ")" & vbCrLf & _
"From Angle: " & pInCArc.FromAngle & vbCrLf & _
"Central Angle: " & pInCArc.CentralAngle & vbCrLf & _
"To Angle: " & pInCArc.ToAngle & vbCrLf & _
"Radius: " & pInCArc.Radius & vbCrLf & _
"Chord Height: " & pInCArc.ChordHeight & vbCrLf & _
"IsCounterClockwise: " & pInCArc.IsCounterClockwise & vbCrLf & _
"IsMinor: " & pInCArc.IsMinor & vbCrLf & _
"IsLine: " & pInCArc.IsLine & vbCrLf & _
"IsPoint: " & pInCArc.IsPoint)
'IsLine and IsPoint check for degenerate cases of CircularArcs.
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 |