This document is archived and information here might be outdated.  Recommended version.


IAffineTransformation2D3GEN.QueryLinearCoefficients Method (ArcObjects .NET 10.4 SDK)
ArcObjects Library Reference (Geometry)  

IAffineTransformation2D3GEN.QueryLinearCoefficients Method

Returns the linear coefficients which define the two dimensional affine transformation. The array size of the incoming parameters needs to be 6.

[Visual Basic .NET]
Public Sub QueryLinearCoefficients ( _
    ByVal Direction As esriTransformDirection, _
    ByRef params As Double[]& _
)
[C#]
public void QueryLinearCoefficients (
    esriTransformDirection Direction,
    ref Double[]& params
);
[C++]
HRESULT QueryLinearCoefficients(
  esriTransformDirection Direction,
  params* params
);
[C++]

Parameters Direction
Direction is a parameter of type esriTransformDirection params [in, out] params is a parameter of type

Product Availability

Available with ArcGIS Engine, ArcGIS Desktop, and ArcGIS Server.
[C#]

//This example demonstrates how to use the
//QueryLinearCoefficients/SetLinearCoefficients methods
private void SetLinearCoefficients_test()
{
    try
    {
        IAffineTransformation2D3GEN affineTransformation=new AffineTransformation2D() as IAffineTransformation2D3GEN;
        //Define a rotation, translation and scale values
        double rotation=0.0;
        double xTranslation=10.0;
        double yTranslation=10.0;
        double xScale=2.0;
        double yScale=2.0;
        //Define the expected linear coefficients based on the defined
        //rotation, translation and scale values
        double[] expectedParameters=new double[6];
        //a
        expectedParameters[0]=xScale * Math.Cos(rotation);
        //b
        expectedParameters[1]=yScale * ((Math.Tan(0) * Math.Cos(rotation)) - Math.Sin(rotation));
        //c
        expectedParameters[2]=xTranslation;
        //d
        expectedParameters[3]=xScale * Math.Sin(rotation);
        //e
        expectedParameters[4]=yScale * ((Math.Tan(0) * Math.Sin(rotation)) + Math.Cos(rotation));
        //f
        expectedParameters[5]=yTranslation;
        //Set the linear coefficients
        affineTransformation.SetLinearCoefficients(esriTransformDirection.esriTransformForward, ref expectedParameters);
        //Get the linear coefficients
        double[] outPutParameters=new double[6];
        affineTransformation.QueryLinearCoefficients(esriTransformDirection.esriTransformForward, ref outPutParameters);
        //Queried Paramaters
        String queriedParamters="";
        for (int i=0; i < outPutParameters.Length; i++)
        {
            queriedParamters=queriedParamters + i + " , " + outPutParameters[i] + "\n";
        }
        System.Windows.Forms.MessageBox.Show(queriedParamters);
        //Create a polygon
        ISegmentCollection tranformPolygon=new Polygon() as ISegmentCollection;
        IEnvelope envelope=new EnvelopeClass();
        envelope.PutCoords(0, 0, 10, 10);
        tranformPolygon.SetRectangle(envelope);
        //Print the polygon coordinates
        IPointCollection polygonPointCollection=tranformPolygon as IPointCollection;
        String message="*** Polygon coordinates before transformation ***\n";
        for (int i=0; i < polygonPointCollection.PointCount; i++)
        {
            message=message + i + " , " + polygonPointCollection.get_Point(i).X + " , " + polygonPointCollection.get_Point(i).Y + "\n";
        }

        ITransform2D transformator=tranformPolygon as ITransform2D;
        //Transform the polygon
        transformator.Transform(esriTransformDirection.esriTransformForward, affineTransformation as ITransformation);
        //Print the polygon coordinates
        IPointCollection transformedPoints=transformator as IPointCollection;
        message=message + "*** Polygon coordinates after transformation ***\n";
        for (int i=0; i < transformedPoints.PointCount; i++)
        {
            message=message + i + " , " + transformedPoints.get_Point(i).X + " , " + transformedPoints.get_Point(i).Y + "\n";
        }
        System.Windows.Forms.MessageBox.Show(message);
    }
    catch (Exception e)
    {
        System.Windows.Forms.MessageBox.Show(e.Message);
    }
}

[Visual Basic .NET]

    'This example demonstrates how to use the
    'QueryLinearCoefficients/SetLinearCoefficients methods
    Private Sub SetLinearCoefficients_test()
        On Error GoTo ErrorHandler
        Dim i As Long, pAffineTransformation2D3 As IAffineTransformation2D3GEN
        Dim pTransform2D As ITransform2D, dParamsOut(0 To 5) As Double
        Dim dParamsExpected(0 To 5) As Double, dRotation As Double
        Dim dXTranslation As Double, dYTranslation As Double
        Dim dXScale As Double, dYScale As Double
        Dim lFlag As Long, pTranformPolygon As ISegmentCollection
        Dim pEnv As IEnvelope, pc As IClone
        Dim pgOri As IGeometry, pTrans2D As ITransform2D
        Dim ptcOut As IPointCollection

        pAffineTransformation2D3=New AffineTransformation2D
        'Define a rotation, translation and scale values
        dRotation=0
        dXTranslation=10
        dYTranslation=10
        dXScale=2
        dYScale=2
        'Define the expected linear coefficients based on the defined
        'rotation, translation and scale values
        'a
        dParamsExpected(0)=dXScale * Math.Cos(dRotation)
        'b
        dParamsExpected(1)=dYScale * ((Math.Tan(0) * Math.Cos(dRotation)) - Math.Sin(dRotation))
        'c
        dParamsExpected(2)=dXTranslation
        'd
        dParamsExpected(3)=dXScale * Math.Sin(dRotation)
        'e
        dParamsExpected(4)=dYScale * ((Math.Tan(0) * Math.Sin(dRotation)) + Math.Cos(dRotation))
        'f
        dParamsExpected(5)=dYTranslation
        'Set the linear coefficients
        pAffineTransformation2D3.SetLinearCoefficients(esriTransformDirection.esriTransformForward, dParamsExpected)
        'Get the linear coefficients
        pAffineTransformation2D3.QueryLinearCoefficients(esriTransformDirection.esriTransformForward, dParamsOut)
        Debug.Print("*** Queried Paramaters ***")
        For i=0 To 5
            Debug.Print(i & " , " & dParamsOut(i))
        Next
        'Create a polygon
        pTranformPolygon=New Polygon
        pEnv=New Envelope
        pEnv.PutCoords(0, 0, 10, 10)
        pTranformPolygon.SetRectangle(pEnv)
        'Print the polygon coordinates
        ptcOut=pTranformPolygon
        Debug.Print("*** Polygon coordinates before transformation ***")
        For i=0 To ptcOut.PointCount - 1
            Debug.Print(i & " , " & ptcOut.Point(i).X & " , " & ptcOut.Point(i).Y)
        Next
        pTrans2D=pTranformPolygon
        'Transform the polygon
        pTrans2D.Transform(esriTransformDirection.esriTransformForward, pAffineTransformation2D3)
        'Print the polygon coordinates
        ptcOut=pTrans2D
        Debug.Print("*** Polygon coordinates after transformation ***")
        For i=0 To ptcOut.PointCount - 1
            Debug.Print(i & " , " & ptcOut.Point(i).X & " , " & ptcOut.Point(i).Y)
        Next


        Exit Sub
ErrorHandler:
        Debug.Print(Err.Description)
    End Sub

See Also

IAffineTransformation2D3GEN Interface