This document is archived and information here might be outdated. Recommended version. |
Defines the best conformal affine transformation between two sets of points. Can be used to register paper maps on a digitizer.
[Visual Basic .NET] Public Sub DefineConformalFromControlPoints ( _ ByRef fromPoints As IPoint[], _ ByRef toPoints As IPoint[] _ )
[C#] public void DefineConformalFromControlPoints ( ref IPoint[] fromPoints, ref IPoint[] toPoints );
[C++]
HRESULT DefineConformalFromControlPoints(
SAFEARRAY(IPoint)** fromPoints,
SAFEARRAY(IPoint)** toPoints
);
[C++]
Parameters fromPoints [in]
fromPoints is a parameter of type SAFEARRAY(IPoint*)* toPoints [in]
toPoints is a parameter of type SAFEARRAY(IPoint*)*
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