ArcObjects Library Reference (Geometry)  

IAffineTransformation2D.Rotate Method

Incorporates a rotation (in radians) into the transformation.

[Visual Basic .NET]
Public Sub Rotate ( _
    ByVal da As Double _
)
[C#]
public void Rotate (
    double da
);
[C++]
HRESULT Rotate(
  double da
);
[C++]

Parameters

da   da is a parameter of type double

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.

Description

Rotates the existing affine transformation by da radians around (0,0).

Remarks

Note: The Move, Scale, and Rotate transformations are cumulative they add the transformation specified to any existing transformation in an AffineTransformation2D object.

[C#]

private void RotateAroundPoint()
{
    //Point to be rotated
    IPoint rotatePoint = new ESRI.ArcGIS.Geometry.Point();
    rotatePoint.PutCoords(2, 2);

    //Point around which to rotate
    IPoint centerPoint = new ESRI.ArcGIS.Geometry.Point();
    centerPoint.PutCoords(1, 1);
    //Rotation Angle
    double angle = 45 * Math.PI / 180.0;
    //Rotate Around pCenter
    IAffineTransformation2D3GEN affineTransformation = new AffineTransformation2D() as IAffineTransformation2D3GEN;
    affineTransformation.Move(-centerPoint.X, -centerPoint.Y);
    affineTransformation.Rotate(angle);
    affineTransformation.Move(centerPoint.X, centerPoint.Y);
    ITransform2D transformator = rotatePoint as ITransform2D;
    transformator.Transform(esriTransformDirection.esriTransformForward, affineTransformation as ITransformation);
    //Set up Comparison Point
    //This is the point the transformation should result in
    IPoint comparePoint = new ESRI.ArcGIS.Geometry.Point();
    comparePoint.PutCoords(2, 2);
    transformator = comparePoint as ITransform2D;
    transformator.Rotate(centerPoint, angle);
    System.Windows.Forms.MessageBox.Show(
        "Using IAffineTransformation2D.Rotate:  Point X:" + rotatePoint.X + ", Y:" + rotatePoint.Y + "\n" +
        "Using IAffineTransformation2D::Rotate,  Point X:" + rotatePoint.X + ", Y:" + rotatePoint.Y + "\n" +
        "Using ITransform2D::Rotate,  Point X: " + comparePoint.X + ", Y:" + comparePoint.Y + "\n" +
        "Did X coordinates match? " + (rotatePoint.X == comparePoint.X) + "\n" +
        "Did Y coordinates match? " + (rotatePoint.Y == comparePoint.Y)
    );
}

[Visual Basic .NET]

    Private Sub RotateAroundPoint()
        'Point to be rotated
        Dim pPt As IPoint
        pPt = New Point
        pPt.PutCoords(2, 2)

        'Point around which to rotate
        Dim pCenter As IPoint
        pCenter = New Point
        pCenter.PutCoords(1, 1)

        'Rotation Angle
        Dim dAngle As Double
        Dim dPi As Double
        dPi = 4 * Math.Atan(1)
        dAngle = 45 * dPi / 180

        'Rotate Around pCenter
        Dim pA2D As IAffineTransformation2D
        pA2D = New AffineTransformation2D
        pA2D.Move(-pCenter.x, -pCenter.y)
        pA2D.Rotate(dAngle)
        pA2D.Move(pCenter.x, pCenter.y)
        Dim pT2D As ITransform2D
        pT2D = pPt
        pT2D.Transform(esriTransformDirection.esriTransformForward, pA2D)

        'Set up Comparison Point
        'This is the point the transformation should result in
        Dim pComparePt As IPoint
        pComparePt = New Point
        pComparePt.PutCoords(2, 2)
        pT2D = pComparePt
        pT2D.Rotate(pCenter, dAngle)

        Debug.Print("Using IAffineTransformation2D::Rotate,  Point X:" & pPt.x & ", Y:" & pPt.y)
        Debug.Print("Using ITransform2D::Rotate,  Point X:" & pComparePt.x & ", Y:" & pComparePt.y)
        Debug.Print("Did X coordinates match? " & (pPt.x = pComparePt.x))
        Debug.Print("Did Y coordinates match? " & (pPt.y = pComparePt.y))
    End Sub

See Also

IAffineTransformation2D Interface

.NET Samples

Create a custom marker placement for placing markers around a point (Code Files: AroundPoint) |