Provides access to members that define and manipulate affine transformations. IAffineTransformation2D3GEN is generic version of IAffineTransformation2D3
Members
Name | Description | |
---|---|---|
DefineConformalFromControlPoints | Defines the best conformal affine transformation between two sets of points. Can be used to register paper maps on a digitizer. | |
DefineFromControlPoints | Defines the best affine transformation between two sets of points. Can be used to register paper maps on a digitizer. | |
DefineFromEnvelopes | Defines a transformation that maps a point relative to one envelope to a similar position relative to another envelope. | |
DefineFromEnvelopesEx | Defines a transformation that maps a point relative to one envelope to a similar position relative to another envelope. | |
DefineReflection | Defines a transformation that can perform a reflection about the line l. | |
GetControlPointError | Returns the errors involved in moving control point i from the 'from' to 'to' system. These error terms are valid after using DefineFromControlPoints/Ex to define the transformation. | |
GetRMSError | RMS (Root Mean Square) error expressed relative to the 'from' and 'to' points defining the transformation. These error terms are valid after using DefineFromControlPoints/Ex to define the transformation. | |
IsReflective | Indicates if the transformation contains a reflection (determinant is negative). | |
Move | Incorporates a translation factor into the transformation. | |
MoveOrigin | The origin of accumulated transformations used when projecting an affine transformation to a different spatial reference system. | |
MoveOrigin | The origin of accumulated transformations used when projecting an affine transformation to a different spatial reference system. | |
MoveVector | Performs an X and Y translation defined by a 2D vector. | |
PostMultiply | Post-multiplies the transformation by another transformation. | |
PreMultiply | Pre-multiplies the transformation by another transformation. | |
Project | Moves this transformation into another spatial reference. If the transformations contains only translations, then use the MoveOrigin property to define an equivalent translation in the new spatial reference. | |
QueryLinearCoefficients | Returns the linear coefficients which define the two dimensional affine transformation. The array size of the incoming parameters needs to be 6. | |
Reset | Resets the tranformation. | |
Rotate | Incorporates a rotation (in radians) into the transformation. | |
Rotation | The rotation angle. Will not be able if different x/y scale factors have been incorporated into the transformation. | |
Scale | Incorporates scale factors into the transformation. | |
SetLinearCoefficients | Sets the linear coefficients which define the two dimensional affine transformation. The array size of the incoming parameters needs to be 6. | |
SpatialReference | The spatial reference in which this transformation is meaningful. | |
TransformMeasuresFF | Transforms floating point measures to floating point measures (or do the inverse). | |
TransformMeasuresFI | Transforms floating point measures to integer measures (or do the inverse). | |
TransformMeasuresIF | Transforms integer measures to floating point measures (or do the inverse). | |
TransformMeasuresII | Transforms integer measures to integer measures (or do the inverse). | |
TransformPointsFF | Transforms floating point points to floating point points (or do the inverse). | |
TransformPointsFI | Transforms floating point points to integer points (or do the inverse). | |
TransformPointsIF | Transforms integer points to floating point points (or do the inverse). | |
TransformPointsII | Transforms integer points to integer points (or do the inverse). | |
XScale | The scale along the X axis. | |
XTranslation | The translation along the X axis. | |
YScale | The scale along the Y axis. | |
YTranslation | The translation along the Y axis. |
IAffineTransformation2D3GEN.DefineConformalFromControlPoints Method
Defines the best conformal affine transformation between two sets of points. Can be used to register paper maps on a digitizer.
Public Sub DefineConformalFromControlPoints ( _
ByRef fromPoints As IPoint[], _
ByRef toPoints As IPoint[] _
)
public void DefineConformalFromControlPoints (
ref IPoint[] fromPoints,
ref IPoint[] toPoints
);
private void DefineConformalFromControlPoints()
{
//The following controls point define a translation of 10 along the X Axis
IPoint[] fromPoints = new IPoint[2];
fromPoints[0] = CreatePoint(0, 0);
fromPoints[1] = CreatePoint(0, 10);
//To point
IPoint[] toPoints = new IPoint[2];
toPoints[0] = CreatePoint(10, 0);
toPoints[1] = CreatePoint(10, 10);
//TransformPoint
IPoint transformPoint = new ESRI.ArcGIS.Geometry.Point();
transformPoint.PutCoords(5, 5);
IAffineTransformation2D3GEN affineTransformation = new AffineTransformation2D() as IAffineTransformation2D3GEN;
//The method requires as inputs the fromPoints and toPoints array
affineTransformation.DefineConformalFromControlPoints(ref fromPoints, ref toPoints);
//The affine transformation can then be used as input in the ITransform2D.Transform method
ITransform2D transformator = transformPoint as ITransform2D;
transformator.Transform(esriTransformDirection.esriTransformForward, affineTransformation as ITransformation);
}
private IPoint CreatePoint(double x, double y)
{
IPoint pnt = new PointClass();
pnt.X = x;
pnt.Y = y;
return pnt;
}
Public Sub DefineConformalFromControlPoints()
Dim ptfrom(1) As ESRI.ArcGIS.Geometry.IPoint, ptto(1) As ESRI.ArcGIS.Geometry.IPoint, i As Long, paffine As ESRI.ArcGIS.Geometry.IAffineTransformation2D3GEN
Dim ptrns As ESRI.ArcGIS.Geometry.ITransform2D
For i = 0 To 1
ptfrom(i) = New ESRI.ArcGIS.Geometry.Point
ptto(i) = New ESRI.ArcGIS.Geometry.Point
Next
'The following controls point define a translation of 10 along the X Axis
ptfrom(0).PutCoords(0, 0)
ptfrom(1).PutCoords(0, 10)
ptto(0).PutCoords(10, 0)
ptto(1).PutCoords(10, 10)
paffine = New ESRI.ArcGIS.Geometry.AffineTransformation2D
'The method requires as inputs the number of points and a pointer
'to first object in the array of IPoint
paffine.DefineConformalFromControlPoints(ptfrom, ptto)
'TransformPoint
Dim transformPoint As ESRI.ArcGIS.Geometry.IPoint
transformPoint = New ESRI.ArcGIS.Geometry.Point
transformPoint.PutCoords(5, 5)
'The affine transformation can then be used as input in the ITransform2D::TransForm method
ptrns = transformPoint
ptrns.Transform(ESRI.ArcGIS.Geometry.esriTransformDirection.esriTransformForward, paffine)
End Sub
IAffineTransformation2D3GEN.DefineFromControlPoints Method
Defines the best affine transformation between two sets of points. Can be used to register paper maps on a digitizer.
Public Sub DefineFromControlPoints ( _
ByRef fromPoints As IPoint[], _
ByRef toPoints As IPoint[] _
)
public void DefineFromControlPoints (
ref IPoint[] fromPoints,
ref IPoint[] toPoints
);
//This example demonstrates how to use the IAffineTransformation2D3GEN.DefineFromControlPoints method
public void transformPolygon()
{
//From point
IPoint[] fromPoints = new IPoint[4];
fromPoints[0] = CreatePoint(0, 0);
fromPoints[1] = CreatePoint(0, 1);
fromPoints[2] = CreatePoint(1, 1);
fromPoints[3] = CreatePoint(1, 0);
//To point
IPoint[] toPoints = new IPoint[4];
toPoints[0] = CreatePoint(10, 10);
toPoints[1] = CreatePoint(10, 15);
toPoints[2] = CreatePoint(15, 15);
toPoints[3] = CreatePoint(15, 10);
//Create polygon
IGeometry segment1 = CreateLineXY(0, 0, 0, 1) as IGeometry;
IGeometry segment2 = CreateLineXY(0, 1, 1, 1) as IGeometry;
IGeometry segment3 = CreateLineXY(0, 1, 0, 0) as IGeometry;
ISegmentCollection segmentCollection = new Polygon() as ISegmentCollection;
object Missing = Type.Missing;
segmentCollection.AddSegment(segment1 as ISegment, ref Missing, ref Missing);
segmentCollection.AddSegment(segment2 as ISegment, ref Missing, ref Missing);
segmentCollection.AddSegment(segment3 as ISegment, ref Missing, ref Missing);
IPolygon polygon = segmentCollection as IPolygon;
//Define the transformation
IAffineTransformation2D3GEN affineTransformation2D = new AffineTransformation2DClass();
affineTransformation2D.DefineFromControlPoints(ref fromPoints, ref toPoints);
//Transform
ITransform2D transform2D = polygon as ITransform2D;
transform2D.Transform(esriTransformDirection.esriTransformForward, affineTransformation2D as ITransformation);
}
private IPoint CreatePoint(double x, double y)
{
IPoint point = new ESRI.ArcGIS.Geometry.Point();
point.X = x;
point.Y = y;
return point;
}
public ILine CreateLineXY(double x1, double y1, double x2, double y2)
{
ILine line = new Line();
line.FromPoint = CreatePoint(x1, y1);
line.ToPoint = CreatePoint(x2, y2);
return line;
}
public ILine CreateLine(IPoint fromPoint, IPoint toPoint)
{
ILine line = new Line();
line.PutCoords(fromPoint, toPoint);
return line;
}
'This example demonstrates how to use the IAffineTransformation::DefineFromControlPoints method.
Public Sub AffTrans2D_DefFromPts()
'From point
Dim pPtFrom(0 To 3) As ESRI.ArcGIS.Geometry.IPoint
pPtFrom(0) = CreatePoint(0, 0)
pPtFrom(1) = CreatePoint(0, 1)
pPtFrom(2) = CreatePoint(1, 1)
pPtFrom(3) = CreatePoint(1, 0)
'To point
Dim pPtTo(0 To 3) As ESRI.ArcGIS.Geometry.IPoint
pPtTo(0) = CreatePoint(10, 10)
pPtTo(1) = CreatePoint(10, 15)
pPtTo(2) = CreatePoint(15, 15)
pPtTo(3) = CreatePoint(15, 10)
'Create polygon
Dim pSeg1 As ESRI.ArcGIS.Geometry.IGeometry
pSeg1 = CreateLineXY(0, 0, 0, 1)
Dim pSeg2 As ESRI.ArcGIS.Geometry.IGeometry
pSeg2 = CreateLineXY(0, 1, 1, 1)
Dim pSeg3 As ESRI.ArcGIS.Geometry.IGeometry
pSeg3 = CreateLineXY(1, 1, 0, 0)
Dim pPolygon As ESRI.ArcGIS.Geometry.ISegmentCollection
pPolygon = New ESRI.ArcGIS.Geometry.Polygon
pPolygon.AddSegment(pSeg1)
pPolygon.AddSegment(pSeg2)
pPolygon.AddSegment(pSeg3)
Dim pPoly As ESRI.ArcGIS.Geometry.IPolygon
pPoly = pPolygon
'Define the transformation
Dim pAffineTrans2D As ESRI.ArcGIS.Geometry.IAffineTransformation2D3GEN
pAffineTrans2D = New ESRI.ArcGIS.Geometry.AffineTransformation2D
pAffineTrans2D.DefineFromControlPoints(pPtFrom, pPtTo)
Dim pTransform2d As ESRI.ArcGIS.Geometry.ITransform2D
'Transform
pTransform2d = pPolygon
pTransform2d.Transform(ESRI.ArcGIS.Geometry.esriTransformDirection.esriTransformForward, pAffineTrans2D)
End Sub
Public Function CreatePoint(ByVal XVal As Double, ByVal YVal As Double) As ESRI.ArcGIS.Geometry.IPoint
CreatePoint = New ESRI.ArcGIS.Geometry.Point
CreatePoint.X = XVal
CreatePoint.Y = YVal
End Function
Public Function CreateLineXY(ByVal X1 As Double, ByVal Y1 As Double, ByVal X2 As Double, ByVal Y2 As Double) As ESRI.ArcGIS.Geometry.ILine
CreateLineXY = CreateLine(CreatePoint(X1, Y1), CreatePoint(X2, Y2))
End Function
Public Function CreateLine(ByVal pPoint1 As ESRI.ArcGIS.Geometry.IPoint, ByVal pPoint2 As ESRI.ArcGIS.Geometry.IPoint) As ESRI.ArcGIS.Geometry.ILine
CreateLine = New ESRI.ArcGIS.Geometry.Line
CreateLine.PutCoords(pPoint1, pPoint2)
End Function
IAffineTransformation2D3GEN.DefineFromEnvelopes Method
Defines a transformation that maps a point relative to one envelope to a similar position relative to another envelope.
Public Sub DefineFromEnvelopes ( _
ByVal from As IEnvelope, _
ByVal to As IEnvelope _
)
public void DefineFromEnvelopes (
IEnvelope from,
IEnvelope to
);
IAffineTransformation2D3GEN.DefineFromEnvelopesEx Method
Defines a transformation that maps a point relative to one envelope to a similar position relative to another envelope.
Public Sub DefineFromEnvelopesEx ( _
ByVal from As IEnvelope, _
ByVal to As IEnvelope, _
ByVal outFrom As IEnvelope, _
ByVal assumeFalseOrigin As Boolean, _
ByVal keepAspect As Boolean, _
ByVal flipIt As Boolean _
)
public void DefineFromEnvelopesEx (
IEnvelope from,
IEnvelope to,
IEnvelope outFrom,
bool assumeFalseOrigin,
bool keepAspect,
bool flipIt
);
IAffineTransformation2D3GEN.DefineReflection Method
Defines a transformation that can perform a reflection about the line l.
Public Sub DefineReflection ( _
ByVal l As ILine _
)
public void DefineReflection (
ILine l
);
IAffineTransformation2D3GEN.GetControlPointError Method
Returns the errors involved in moving control point i from the 'from' to 'to' system. These error terms are valid after using DefineFromControlPoints/Ex to define the transformation.
Public Sub GetControlPointError ( _
ByVal i As Integer, _
ByRef fromError As Double, _
ByRef toError As Double _
)
public void GetControlPointError (
int i,
ref double fromError,
ref double toError
);
/// This example demonstrates how to get the GetControlPointError
///for an AffineTransformation
public void GetControlPointError_Example()
{
try
{
//From point
IPoint[] fromPoints = new IPoint[4];
fromPoints[0] = CreatePoint(0, 0);
fromPoints[1] = CreatePoint(0, 1);
fromPoints[2] = CreatePoint(1, 0);
fromPoints[3] = CreatePoint(1, 1);
//To point
IPoint[] toPoints = new IPoint[4];
toPoints[0] = CreatePoint(5, 5);
toPoints[1] = CreatePoint(5, 6);
toPoints[2] = CreatePoint(6, 5);
toPoints[3] = CreatePoint(6, 6);
//Create an AffineTransformation2D object
IAffineTransformation2D3GEN affineTransformation2D = new AffineTransformation2DClass();
affineTransformation2D.DefineFromControlPoints(ref fromPoints, ref toPoints);
double fromError = 0;
double toError = 0;
for (int i = 0; i < 4; i++)
{
affineTransformation2D.GetControlPointError(i, ref fromError, ref toError);
System.Windows.Forms.MessageBox.Show("The fromError value is 0 because the control points define a perfect fit : " + fromError);
System.Windows.Forms.MessageBox.Show("The toError value is 0 because the control points define a perfect fit : " + toError);
}
//Now lets introduce some error by modifying one control point to break the perfect fit
toPoints[3] = CreatePoint(5.9, 5.9);
//Redefine the affine transformation
affineTransformation2D.DefineFromControlPoints(ref fromPoints, ref toPoints);
affineTransformation2D.GetRMSError(ref fromError, ref toError);
System.Windows.Forms.MessageBox.Show("The fromError value is 0.039 because the control points do not define a perfect fit : " + fromError);
System.Windows.Forms.MessageBox.Show("The toError value is 0.035 because the control points do not define a perfect fit : " + toError);
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.Message);
}
}
public IPoint CreatePoint(double x, double y)
{
IPoint point = new ESRI.ArcGIS.Geometry.Point();
point.X = x;
point.Y = y;
return point;
}
'This example demonstrates how to get the RMS error
'for all the control points of an AffineTransformation
Private Sub GetControlPointError_example()
On Error GoTo ErrorHandler
'Create an AffineTransformation2D object
Dim pA2D As IAffineTransformation2D3GEN
pA2D = New AffineTransformation2D
Dim pArrFromPts(3) As IPoint
pArrFromPts(0) = New Point
pArrFromPts(1) = New Point
pArrFromPts(2) = New Point
pArrFromPts(3) = New Point
Dim pArrToPts(3) As IPoint
pArrToPts(0) = New Point
pArrToPts(1) = New Point
pArrToPts(2) = New Point
pArrToPts(3) = New Point
'Define the Affine using control points
'forming a perfect fit
pArrFromPts(0).PutCoords(0, 0)
pArrFromPts(1).PutCoords(0, 1)
pArrFromPts(2).PutCoords(1, 0)
pArrFromPts(3).PutCoords(1, 1)
pArrToPts(0).PutCoords(5, 5)
pArrToPts(1).PutCoords(5, 6)
pArrToPts(2).PutCoords(6, 5)
pArrToPts(3).PutCoords(6, 6)
pA2D.DefineFromControlPoints(pArrFromPts, pArrToPts)
Dim dFromErr As Double, dToErr As Double
Dim i As Long
Debug.Print("**** Control point errors - Perfect fit ****")
For i = 0 To 3
pA2D.GetControlPointError(i, dFromErr, dToErr)
Debug.Print("FromErr on control point" & i & " = " & dFromErr)
Debug.Print("ToErr on control point" & i & " = " & dToErr)
Next
'Now lets introduce some error by modifying one control point to break the perfect fit
pArrToPts(3).PutCoords(5.9, 5.9)
pA2D.DefineFromControlPoints(pArrFromPts, pArrToPts)
Debug.Print("**** Control point errors - With error ****")
For i = 0 To 3
pA2D.GetControlPointError(i, dFromErr, dToErr)
Debug.Print("FromErr on control point" & i & " = " & dFromErr)
Debug.Print("ToErr on control point" & i & " = " & dToErr)
Next
Exit Sub
ErrorHandler:
Debug.Print(Err.Description)
End Sub
IAffineTransformation2D3GEN.GetRMSError Method
RMS (Root Mean Square) error expressed relative to the 'from' and 'to' points defining the transformation. These error terms are valid after using DefineFromControlPoints/Ex to define the transformation.
Public Sub GetRMSError ( _
ByRef fromError As Double, _
ByRef toError As Double _
)
public void GetRMSError (
ref double fromError,
ref double toError
);
/// This example demonstrates how to get the RMS error
///for an AffineTransformation
public void GetRMSError_Example()
{
try
{
//From point
IPoint[] fromPoints = new IPoint[4];
fromPoints[0] = CreatePoint(0, 0);
fromPoints[1] = CreatePoint(0, 1);
fromPoints[2] = CreatePoint(1, 0);
fromPoints[3] = CreatePoint(1, 1);
//To point
IPoint[] toPoints = new IPoint[4];
toPoints[0] = CreatePoint(5, 5);
toPoints[1] = CreatePoint(5, 6);
toPoints[2] = CreatePoint(6, 5);
toPoints[3] = CreatePoint(6, 6);
//Create an AffineTransformation2D object
IAffineTransformation2D3GEN affineTransformation2D = new AffineTransformation2DClass();
affineTransformation2D.DefineFromControlPoints(ref fromPoints, ref toPoints);
double fromError = 0;
double toError = 0;
affineTransformation2D.GetRMSError(ref fromError, ref toError);
System.Windows.Forms.MessageBox.Show("The fromError value is 0 because the control points define a perfect fit : " + fromError);
System.Windows.Forms.MessageBox.Show("The toError value is 0 because the control points define a perfect fit : " + toError);
//Now lets introduce some error by modifying one control point to break the perfect fit
toPoints[3] = CreatePoint(5.9, 5.9);
//Redefine the affine transformation
affineTransformation2D.DefineFromControlPoints(ref fromPoints, ref toPoints);
affineTransformation2D.GetRMSError(ref fromError, ref toError);
System.Windows.Forms.MessageBox.Show("The fromError value is 0.039 because the control points do not define a perfect fit : " + fromError);
System.Windows.Forms.MessageBox.Show("The toError value is 0.035 because the control points do not define a perfect fit : " + toError);
}
catch (Exception e)
{
System.Windows.Forms.MessageBox.Show(e.Message);
}
}
public IPoint CreatePoint(double x, double y)
{
IPoint point = new ESRI.ArcGIS.Geometry.Point();
point.X = x;
point.Y = y;
return point;
}
'This example demonstrates how to get the RMS error
'for an AffineTransformation
Private Sub GetRMSError_Example()
On Error GoTo ErrorHandler
'Create an IAffineTransformation2D3Gen object
Dim pA2D As IAffineTransformation2D3GEN
pA2D = New AffineTransformation2D
Dim pArrFromPts(3) As IPoint
pArrFromPts(0) = New Point
pArrFromPts(1) = New Point
pArrFromPts(2) = New Point
pArrFromPts(3) = New Point
Dim pArrToPts(3) As IPoint
pArrToPts(0) = New Point
pArrToPts(1) = New Point
pArrToPts(2) = New Point
pArrToPts(3) = New Point
'Define the Affine using control points
'forming a perfect fit
pArrFromPts(0).PutCoords(0, 0)
pArrFromPts(1).PutCoords(0, 1)
pArrFromPts(2).PutCoords(1, 0)
pArrFromPts(3).PutCoords(1, 1)
pArrToPts(0).PutCoords(5, 5)
pArrToPts(1).PutCoords(5, 6)
pArrToPts(2).PutCoords(6, 5)
pArrToPts(3).PutCoords(6, 6)
pA2D.DefineFromControlPoints(pArrFromPts, pArrToPts)
Dim dFromErr As Double, dToErr As Double
pA2D.GetRMSError(dFromErr, dToErr)
Debug.Print("The dFromErr value is 0 because the control points define a perfect fit : " & dFromErr)
Debug.Print("The dToErr value is 0 because the control points define a perfect fit : " & dToErr)
'Now lets introduce some error by modifying one control point to break the perfect fit
pArrToPts(3).PutCoords(5.9, 5.9)
'Redefine the affine transformation
pA2D.DefineFromControlPoints(pArrFromPts, pArrToPts)
pA2D.GetRMSError(dFromErr, dToErr)
Debug.Print("The dFromErr value is 0.039 because the control points do not define a perfect fit : " & dFromErr)
Debug.Print("The dToErr value is 0.035 because the control points do not define a perfect fit : " & dToErr)
Exit Sub
ErrorHandler:
Debug.Print(Err.Description)
End Sub
IAffineTransformation2D3GEN.IsReflective Property
Indicates if the transformation contains a reflection (determinant is negative).
Public ReadOnly Property IsReflective As Boolean
public bool IsReflective {get;}
IAffineTransformation2D3GEN.Move Method
Incorporates a translation factor into the transformation.
Public Sub Move ( _
ByVal dx As Double, _
ByVal dy As Double _
)
public void Move (
double dx,
double dy
);
IAffineTransformation2D3GEN.MoveOrigin Property
The origin of accumulated transformations used when projecting an affine transformation to a different spatial reference system.
Public Property MoveOrigin As IPoint
public IPoint MoveOrigin {get; set;}
IAffineTransformation2D3GEN.MoveOrigin Property
The origin of accumulated transformations used when projecting an affine transformation to a different spatial reference system.
Public Property MoveOrigin As IPoint
public IPoint MoveOrigin {get; set;}
IAffineTransformation2D3GEN.MoveVector Method
Performs an X and Y translation defined by a 2D vector.
Public Sub MoveVector ( _
ByVal movementVector As ILine _
)
public void MoveVector (
ILine movementVector
);
IAffineTransformation2D3GEN.PostMultiply Method
Post-multiplies the transformation by another transformation.
Public Sub PostMultiply ( _
ByVal postTransform As IAffineTransformation2D3GEN _
)
public void PostMultiply (
IAffineTransformation2D3GEN postTransform
);
IAffineTransformation2D3GEN.PreMultiply Method
Pre-multiplies the transformation by another transformation.
Public Sub PreMultiply ( _
ByVal preTransform As IAffineTransformation2D3GEN _
)
public void PreMultiply (
IAffineTransformation2D3GEN preTransform
);
IAffineTransformation2D3GEN.Project Method
Moves this transformation into another spatial reference. If the transformations contains only translations, then use the MoveOrigin property to define an equivalent translation in the new spatial reference.
Public Sub Project ( _
ByVal newSpatialReference As ISpatialReference _
)
public void Project (
ISpatialReference newSpatialReference
);
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.
Public Sub QueryLinearCoefficients ( _
ByVal Direction As esriTransformDirection, _
ByRef params As Double[]& _
)
public void QueryLinearCoefficients (
esriTransformDirection Direction,
ref Double[]& params
);
//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);
}
}
'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
IAffineTransformation2D3GEN.Reset Method
Resets the tranformation.
Public Sub Reset ( _
)
public void Reset (
);
IAffineTransformation2D3GEN.Rotate Method
Incorporates a rotation (in radians) into the transformation.
Public Sub Rotate ( _
ByVal da As Double _
)
public void Rotate (
double da
);
IAffineTransformation2D3GEN.Rotation Property
The rotation angle. Will not be able if different x/y scale factors have been incorporated into the transformation.
Public ReadOnly Property Rotation As Double
public double Rotation {get;}
IAffineTransformation2D3GEN.Scale Method
Incorporates scale factors into the transformation.
Public Sub Scale ( _
ByVal dx As Double, _
ByVal dy As Double _
)
public void Scale (
double dx,
double dy
);
IAffineTransformation2D3GEN.SetLinearCoefficients Method
Sets the linear coefficients which define the two dimensional affine transformation. The array size of the incoming parameters needs to be 6.
Public Sub SetLinearCoefficients ( _
ByVal Direction As esriTransformDirection, _
ByRef params As Double[]& _
)
public void SetLinearCoefficients (
esriTransformDirection Direction,
ref Double[]& params
);
IAffineTransformation2D3GEN.SpatialReference Property
The spatial reference in which this transformation is meaningful.
Public Property SpatialReference As ISpatialReference
public ISpatialReference SpatialReference {get; set;}
IAffineTransformation2D3GEN.TransformMeasuresFF Method
Transforms floating point measures to floating point measures (or do the inverse).
Public Sub TransformMeasuresFF ( _
ByVal Direction As esriTransformDirection, _
ByRef inMeasures As Double[]&, _
ByRef outMeasures As Double[]& _
)
public void TransformMeasuresFF (
esriTransformDirection Direction,
ref Double[]& inMeasures,
ref Double[]& outMeasures
);
IAffineTransformation2D3GEN.TransformMeasuresFI Method
Transforms floating point measures to integer measures (or do the inverse).
Public Sub TransformMeasuresFI ( _
ByVal Direction As esriTransformDirection, _
ByRef inMeasures As Double[]&, _
ByRef outMeasures As Int32[]& _
)
public void TransformMeasuresFI (
esriTransformDirection Direction,
ref Double[]& inMeasures,
ref Int32[]& outMeasures
);
IAffineTransformation2D3GEN.TransformMeasuresIF Method
Transforms integer measures to floating point measures (or do the inverse).
Public Sub TransformMeasuresIF ( _
ByVal Direction As esriTransformDirection, _
ByRef inMeasures As Int32[]&, _
ByRef outMeasures As Double[]& _
)
public void TransformMeasuresIF (
esriTransformDirection Direction,
ref Int32[]& inMeasures,
ref Double[]& outMeasures
);
IAffineTransformation2D3GEN.TransformMeasuresII Method
Transforms integer measures to integer measures (or do the inverse).
Public Sub TransformMeasuresII ( _
ByVal Direction As esriTransformDirection, _
ByRef inMeasures As Int32[]&, _
ByRef outMeasures As Int32[]& _
)
public void TransformMeasuresII (
esriTransformDirection Direction,
ref Int32[]& inMeasures,
ref Int32[]& outMeasures
);
IAffineTransformation2D3GEN.TransformPointsFF Method
Transforms floating point points to floating point points (or do the inverse).
Public Sub TransformPointsFF ( _
ByVal Direction As esriTransformDirection, _
ByRef inPoints As Double[]&, _
ByRef outPoints As Double[]& _
)
public void TransformPointsFF (
esriTransformDirection Direction,
ref Double[]& inPoints,
ref Double[]& outPoints
);
IAffineTransformation2D3GEN.TransformPointsFI Method
Transforms floating point points to integer points (or do the inverse).
Public Sub TransformPointsFI ( _
ByVal Direction As esriTransformDirection, _
ByRef inPoints As Double[]&, _
ByRef outPoints As Int32[]& _
)
public void TransformPointsFI (
esriTransformDirection Direction,
ref Double[]& inPoints,
ref Int32[]& outPoints
);
IAffineTransformation2D3GEN.TransformPointsIF Method
Transforms integer points to floating point points (or do the inverse).
Public Sub TransformPointsIF ( _
ByVal Direction As esriTransformDirection, _
ByRef inPoints As Int32[]&, _
ByRef outPoints As Double[]& _
)
public void TransformPointsIF (
esriTransformDirection Direction,
ref Int32[]& inPoints,
ref Double[]& outPoints
);
IAffineTransformation2D3GEN.TransformPointsII Method
Transforms integer points to integer points (or do the inverse).
Public Sub TransformPointsII ( _
ByVal Direction As esriTransformDirection, _
ByRef inPoints As Int32[]&, _
ByRef outPoints As Int32[]& _
)
public void TransformPointsII (
esriTransformDirection Direction,
ref Int32[]& inPoints,
ref Int32[]& outPoints
);
IAffineTransformation2D3GEN.XScale Property
The scale along the X axis.
Public ReadOnly Property XScale As Double
public double XScale {get;}
IAffineTransformation2D3GEN.XTranslation Property
The translation along the X axis.
Public ReadOnly Property XTranslation As Double
public double XTranslation {get;}
IAffineTransformation2D3GEN.YScale Property
The scale along the Y axis.
Public ReadOnly Property YScale As Double
public double YScale {get;}
IAffineTransformation2D3GEN.YTranslation Property
The translation along the Y axis.
Public ReadOnly Property YTranslation As Double
public double YTranslation {get;}
Classes that implement IAffineTransformation2D3GEN
Classes | Description |
---|---|
AffineTransformation2D | A two dimensional affine transformation. |