protected ReferencePointBasedTransform(MappingGridVector2[] points, GridRectangle mappedBounds, GridRectangle controlBounds, TransformInfo info) : base(info) { this.MapPoints = points; this.MappedBounds = mappedBounds; this.ControlBounds = controlBounds; }
protected ReferencePointBasedTransform(MappingGridVector2[] points, TransformInfo info) : base(info) { //List<MappingGridVector2> listPoints = new List<MappingGridVector2>(points); //MappingGridVector2.RemoveDuplicates(listPoints); //this.MapPoints = listPoints.ToArray(); this.MapPoints = points; }
public GridTransform(MappingGridVector2[] points, GridRectangle mappedBounds, int gridSizeX, int gridSizeY, TransformInfo info) : base(points, mappedBounds, info) { GridSizeX = gridSizeX; GridSizeY = gridSizeY; Array.Sort(points); Debug.Assert(points.Length == gridSizeX * gridSizeY, "Invalid argument to GridTransform constructor. Number of points incorrect"); if (points.Length != gridSizeX * gridSizeY) { throw new ArgumentException("GridTransform constructor. Number of points incorrect"); } _TriangleIndicies = GridTransformHelper.TrianglesForGrid(GridSizeX, GridSizeY); }
public void TestMethod1() { GridVector2[] ControlPoints = { new GridVector2(104.8445, 75.1144), new GridVector2(102.7622, 163.9576), new GridVector2(257.5437, 79.9730), new GridVector2(258.2378, 168.1221)}; GridVector2[] MappedPoints = { new GridVector2(68.7519, 127.1710), new GridVector2(87.4923, 199.3560), new GridVector2(263.7905, 77.8907), new GridVector2(281.1427, 149.3817)}; double[,] BetaMatrix = Geometry.Transforms.RBFTransform.CreateBetaMatrixWithLinear(ControlPoints, Geometry.Transforms.RBFTransform.StandardBasisFunction); double[] SolutionMatrix = Geometry.Transforms.RBFTransform.CreateSolutionMatrixWithLinear(MappedPoints); //double[] Weights = GridMatrix.LinSolve(BetaMatrix, SolutionMatrix); double[] Weights = RBFTransform.CalculateRBFWeights(MappedPoints, ControlPoints, RBFTransform.StandardBasisFunction); MappingGridVector2[] Points = new MappingGridVector2[ControlPoints.Length]; for(int i = 0; i < ControlPoints.Length; i++) { Points[i] = new MappingGridVector2(ControlPoints[i], MappedPoints[i]); } RBFTransform transform = new RBFTransform(Points, new TransformInfo()); for (int i = 0; i < ControlPoints.Length; i++) { GridVector2 tPoint = transform.Transform(MappedPoints[i]); Trace.WriteLine(tPoint.ToString() + " should equal " + ControlPoints[i]); Debug.Assert(GridVector2.Distance(tPoint, ControlPoints[i]) < 1.0); } for (int i = 0; i < ControlPoints.Length; i++) { GridVector2 tPoint = transform.InverseTransform(ControlPoints[i]); Trace.WriteLine(tPoint.ToString() + " should equal " + MappedPoints[i]); Debug.Assert(GridVector2.Distance(tPoint, MappedPoints[i]) < 1.0); } }
protected ReferencePointBasedTransform(MappingGridVector2[] points, GridRectangle mappedBounds, TransformInfo info) : this(points, info) { this.MappedBounds = mappedBounds; }
private static ReferencePointBasedTransform ParsePolyTransform(TransformParameters transform, TransformInfo info) { // string filename = System.IO.Path.GetFileName(parts[1]); // string[] fileparts = filename.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); // this.Number = System.Convert.ToInt32(fileparts[1]); //Figure out tile size int ImageWidth = System.Convert.ToInt32(transform.fixedParameters[2]) * 2; int ImageHeight = System.Convert.ToInt32(transform.fixedParameters[3]) * 2; //The poly transform parameters dictate the center of the image double x = transform.fixedParameters[0] - (ImageWidth / 2.0); double y = transform.fixedParameters[1] - (ImageHeight / 2.0); GridVector2 ctrlBotLeft = new GridVector2(x, y); GridVector2 ctrlBotRight = new GridVector2(x + ImageWidth, y); GridVector2 ctrlTopLeft = new GridVector2(x, y + ImageHeight); GridVector2 ctrlTopRight = new GridVector2(x + ImageWidth, y + ImageHeight); GridVector2 mapBotLeft = new GridVector2(0, 0); GridVector2 mapBotRight = new GridVector2(ImageWidth, 0); GridVector2 mapTopLeft = new GridVector2(0, ImageHeight); GridVector2 mapTopRight = new GridVector2(ImageWidth, ImageHeight); MappingGridVector2 BotLeft = new MappingGridVector2(ctrlBotLeft, mapBotLeft); MappingGridVector2 BotRight = new MappingGridVector2(ctrlBotRight, mapBotRight); MappingGridVector2 TopLeft = new MappingGridVector2(ctrlTopLeft, mapTopLeft); MappingGridVector2 TopRight = new MappingGridVector2(ctrlTopRight, mapTopRight); MappingGridVector2[] MapPoints = new MappingGridVector2[] { BotLeft, BotRight, TopLeft, TopRight }; return new GridTransform(MapPoints, new GridRectangle(0, ImageWidth, 0, ImageHeight), 2, 2, info); }
private static void DebugVerifyPointsAreUnique(MappingGridVector2[] listPoints) { //Check for duplicate points for (int i = 1; i < listPoints.Length; i++) { Debug.Assert(listPoints[i - 1].ControlPoint != listPoints[i].ControlPoint, "Duplicate Points found in transform. This breaks Delaunay."); Debug.Assert(listPoints[i - 1].MappedPoint != listPoints[i].MappedPoint, "Duplicate Points found in transform. This breaks Delaunay."); } }
public static MappingGridTriangle TriangleForPoint(int GridSizeX, int GridSizeY, GridRectangle Bounds, MappingGridVector2[] points, int[] TriIndicies, GridVector2 Point) { //Having a smaller epsilon caused false positives. //We just want to know if we are close enough to check with the more time consuming math double epsilon = 5; if (Point.X < Bounds.Left - epsilon) return null; if (Point.X > Bounds.Right + epsilon) return null; if (Point.Y > Bounds.Top + epsilon) return null; if (Point.Y < Bounds.Bottom - epsilon) return null; double OffsetX = Point.X - Bounds.Left; double OffsetY = Point.Y - Bounds.Bottom; double X = (OffsetX / Bounds.Width) * (GridSizeX-1); double Y = (OffsetY / Bounds.Height) * (GridSizeY-1); int iX = (int)X; int iY = (int)Y; //This gives us the grid coordinates which contains two triangles, however there are two triangles. If the fractional parts add up to a number greater than one it is the upper triangle. bool IsUpper = (X - iX) + (Y - iY) > 1; //Check edge case where point is exactly on the right edge of the boundary if (OffsetX + double.Epsilon >= Bounds.Width ) { IsUpper = true; iX--; } else if (OffsetY + double.Epsilon >= Bounds.Height) { IsUpper = true; iY--; } else { IsUpper = (X - iX) + (Y - iY) > 1; } int iTri = (iY * 2) + ((GridSizeY-1) * 2 * iX); //int iTri = (iX * 2) + ((GridSizeX-1) * 2 * iY); iTri += IsUpper ? 1:0; iTri *= 3;//Multiply by three to get the triangle offset MappingGridTriangle mapTri = new MappingGridTriangle(points, TriIndicies[iTri], TriIndicies[iTri + 1], TriIndicies[iTri + 2]); Debug.Assert(mapTri.IntersectsMapped(Point), "Calculated GridTransform does not intersect requested point"); return mapTri; }
public void ParsePolyTransform(string SectionPath, string[] parts) { //Find the dimensions of the grid int iFixedParameters = 0; int iVariableParameters = 0; for (int i = 0; i < parts.Length; i++) { if (parts[i] == "vp") { iVariableParameters = i; continue; } if (parts[i] == "fp") { iFixedParameters = i; break; } } // string filename = System.IO.Path.GetFileName(parts[1]); // string[] fileparts = filename.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); // this.Number = System.Convert.ToInt32(fileparts[1]); //Figure out tile size ImageWidth = System.Convert.ToInt32(System.Convert.ToDouble(parts[iFixedParameters + 4])) * 2; ImageHeight = System.Convert.ToInt32(System.Convert.ToDouble(parts[iFixedParameters + 5])) * 2; //The poly transform parameters dictate the center of the image double x = System.Convert.ToDouble(parts[iFixedParameters + 2]) - (ImageWidth / 2); double y = System.Convert.ToDouble(parts[iFixedParameters + 3]) - (ImageHeight / 2); GridVector2 ctrlBotLeft = new GridVector2(x, y); GridVector2 ctrlBotRight = new GridVector2(x + ImageWidth, y); GridVector2 ctrlTopLeft = new GridVector2(x, y + ImageHeight); GridVector2 ctrlTopRight = new GridVector2(x + ImageWidth, y + ImageHeight); GridVector2 mapBotLeft = new GridVector2(0, 0); GridVector2 mapBotRight = new GridVector2(ImageWidth, 0); GridVector2 mapTopLeft = new GridVector2(0, ImageHeight); GridVector2 mapTopRight = new GridVector2(ImageWidth, ImageHeight); int iStart = mapPoints.Length; MappingGridVector2 BotLeft = new MappingGridVector2(ctrlBotLeft, mapBotLeft); MappingGridVector2 BotRight = new MappingGridVector2(ctrlBotRight, mapBotRight); MappingGridVector2 TopLeft = new MappingGridVector2(ctrlTopLeft, mapTopLeft); MappingGridVector2 TopRight = new MappingGridVector2(ctrlTopRight, mapTopRight); this.mapPoints = new MappingGridVector2[] {BotLeft, BotRight, TopLeft, TopRight}; }
public void ParseTranslateTransform(string SectionPath, string[] parts) { //Find the dimensions of the grid int iFixedParameters = 0; int iVariableParameters = 0; for (int i = 0; i < parts.Length; i++) { if (parts[i] == "vp") { iVariableParameters = i; continue; } if (parts[i] == "fp") { iFixedParameters = i; break; } } //string filename = System.IO.Path.GetFileName(parts[1]); //Figure out tile size if we haven't already ImageWidth = System.Convert.ToInt32(parts[iFixedParameters + 4]) * 2; ImageHeight = System.Convert.ToInt32(parts[iFixedParameters + 5]) * 2; double x = System.Convert.ToDouble(parts[iVariableParameters + 2]); double y = System.Convert.ToDouble(parts[iVariableParameters + 3]); GridVector2 ctrlBotLeft = new GridVector2(x, y); GridVector2 ctrlBotRight = new GridVector2(x + ImageWidth, y); GridVector2 ctrlTopLeft = new GridVector2(x, y + ImageHeight); GridVector2 ctrlTopRight = new GridVector2(x + ImageWidth, y + ImageHeight); GridVector2 mapBotLeft = new GridVector2(0, 0); GridVector2 mapBotRight = new GridVector2(ImageWidth, 0); GridVector2 mapTopLeft = new GridVector2(0, ImageHeight); GridVector2 mapTopRight = new GridVector2(ImageWidth, ImageHeight); MappingGridVector2 BotLeft = new MappingGridVector2(ctrlBotLeft, mapBotLeft); MappingGridVector2 BotRight = new MappingGridVector2(ctrlBotRight, mapBotRight); MappingGridVector2 TopLeft = new MappingGridVector2(ctrlTopLeft, mapTopLeft); MappingGridVector2 TopRight = new MappingGridVector2(ctrlTopRight, mapTopRight); this.mapPoints = new MappingGridVector2[] { BotLeft, BotRight, TopLeft, TopRight }; }
public static MappingGridVector2[] ParseGridTransform(string[] parts, float pixelSpacing, int iFixedParameters, int iVariableParameters, GridRectangle MappedBounds) { //Find the dimensions of the grid MappingGridVector2[] mappings; float MappedWidth = (float)MappedBounds.Width; float MappedHeight = (float)MappedBounds.Height; int gridWidth = System.Convert.ToInt32(System.Convert.ToDouble(parts[iFixedParameters + 4]) + 1.0); int gridHeight = System.Convert.ToInt32(System.Convert.ToDouble(parts[iFixedParameters + 3]) + 1.0); double NumPts = gridHeight * gridWidth; mappings = new MappingGridVector2[gridWidth * gridHeight]; GridVector2[] Points = new GridVector2[System.Convert.ToInt32(NumPts)]; int iPoints = iVariableParameters + 2; for (int i = 0; i < NumPts; i++) { Points[i].X = System.Convert.ToDouble(parts[iPoints + (i * 2)]) * pixelSpacing; Points[i].Y = System.Convert.ToDouble(parts[iPoints + (i * 2) + 1]) * pixelSpacing; } for (int y = 0; y < gridHeight; y++) { int iYOffset = y * gridWidth; for (int x = 0; x < gridWidth; x++) { int i = x + iYOffset; GridVector2 controlPoint = Points[i]; GridVector2 mappedPoint = CoordinateFromGridPos(x, y, gridWidth, gridHeight, MappedWidth, MappedHeight); mappings[i] = new MappingGridVector2(controlPoint, mappedPoint); } } return mappings; }
public void ParseGridTransform(string[] parts) { //Find the dimensions of the grid int iFixedParameters = 0; int iVariableParameters = 0; for (int i = 0; i < parts.Length; i++) { if (parts[i] == "vp") { iVariableParameters = i; continue; } if (parts[i] == "fp") { iFixedParameters = i; break; } } //string filename = System.IO.Path.GetFileName(parts[1]); //string[] fileparts = filename.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); //this.Number = System.Convert.ToInt32(fileparts[1]); int gridWidth = System.Convert.ToInt32(System.Convert.ToDouble(parts[iFixedParameters + 3]) + 1.0); int gridHeight = System.Convert.ToInt32(System.Convert.ToDouble(parts[iFixedParameters + 4]) + 1.0); ImageHeight = System.Convert.ToInt32(System.Convert.ToDouble(parts[iFixedParameters + 8])); ImageWidth = System.Convert.ToInt32(System.Convert.ToDouble(parts[iFixedParameters + 7])); this.MappedBounds.Left = 0; this.MappedBounds.Bottom = 0; this.MappedBounds.Right = ImageWidth; this.MappedBounds.Top = ImageHeight; int NumPts = System.Convert.ToInt32(parts[2]) / 2; GridVector2[] Points = new GridVector2[System.Convert.ToInt32(NumPts)]; // verticies = new VertexPositionNormalTexture[numPts]; Double minX = Double.MaxValue; Double minY = Double.MaxValue; Double maxX = Double.MinValue; Double maxY = Double.MinValue; //Every number in the array is seperated by an empty space in the array for (int i = 0; i < NumPts; i++) { int iPoint = 3 + (i * 2); Double x = System.Convert.ToDouble(parts[iPoint]); Double y = System.Convert.ToDouble(parts[iPoint + 1]); Points[i] = new GridVector2(x, y); //Trace.WriteLine(x.ToString() + ", " + y.ToString(), "Geometry"); if (x < minX) minX = x; if (x > maxX) maxX = x; if (y < minY) minY = y; if (y > maxY) maxY = y; } List<int> indicies = new List<int>(); List<MappingGridVector2> mapList = new List<MappingGridVector2>(gridHeight * gridWidth); List<int> triangleIndicies = new List<int>(); for (int y = 0; y < gridHeight; y++) { for (int x = 0; x < gridWidth; x++) { int i = x + (y * gridWidth); GridVector2 mapPoint = CoordinateFromGridPos(x, y, gridWidth, gridHeight); GridVector2 ctrlPoint = Points[i]; MappingGridVector2 gridPoint = new MappingGridVector2(ctrlPoint, mapPoint); mapList.Add(gridPoint); /* Triangle controlOne = new Triangle(Points[i], Points[i + 1], Points[i + gridWidth]); Vector2 p1 = CoordinateFromGridPos(x, y, gridWidth, gridHeight); Vector2 p2 = CoordinateFromGridPos(x + 1, y, gridWidth, gridHeight); Vector2 p3 = CoordinateFromGridPos(x, y + 1, gridWidth, gridHeight); Triangle mappedOne = new Triangle(p1, p2, p3); mappings.Add(new MappingTriangle(controlOne, mappedOne)); Triangle controlTwo = new Triangle(Points[i + 1], Points[i + gridWidth + 1], Points[i + gridWidth]); Vector2 p4 = CoordinateFromGridPos(x + 1, y, gridWidth, gridHeight); Vector2 p5 = CoordinateFromGridPos(x + 1, y + 1, gridWidth, gridHeight); Vector2 p6 = CoordinateFromGridPos(x, y + 1, gridWidth, gridHeight); Triangle mappedTwo = new Triangle(p4, p5, p6); mappings.Add(new MappingTriangle(controlTwo, mappedTwo)); */ } } for (int y = 0; y < gridHeight-1; y++) { for (int x = 0; x < gridWidth-1; x++) { int botLeft = x + (y * gridWidth); int botRight = (x+1) + (y * gridWidth); int topLeft = x + ((y+1) * gridWidth); int topRight = (x+1) + ((y+1) * gridWidth); int[] triangles = new int[] { botLeft, botRight, topLeft, botRight, topRight, topLeft }; triangleIndicies.AddRange(triangles); } } this.mapPoints = mapList.ToArray(); this.SetPointsAndTriangles(mapList.ToArray(), triangleIndicies.ToArray()); // this.gridIndicies = indicies; }
/// <summary> /// Use this to set points and triangles so we don't have to run the delaunay algorithm. /// </summary> /// <param name="points"></param> /// <param name="triangleIndicies"></param> public void SetPointsAndTriangles(MappingGridVector2[] points, int[] triangleIndicies) { #if DEBUG //Check for duplicate points for (int i = 1; i < points.Length; i++) { Debug.Assert(points[i - 1].ControlPoint != points[i].ControlPoint, "Duplicate Points found in transform. This breaks Delaunay."); } #endif _mapPoints = points; _TriangleIndiciesCache = triangleIndicies; this._CachedMappedBounds = MappingGridVector2.CalculateMappedBounds(this.mapPoints); this._CachedControlBounds = MappingGridVector2.CalculateControlBounds(this.mapPoints); }
public void TransformTestMethodTwo() { // // A simple test adding two transforms built from three points each // GridTransform fixedTransform = new GridTransform(); GridTransform movingTransform = new GridTransform(); GridVector2 fixedV1 = new GridVector2(0, 0); GridVector2 fixedV2 = new GridVector2(10, 0); GridVector2 fixedV3 = new GridVector2(0, 10); GridVector2 fixedV4 = new GridVector2(10, 10); MappingGridVector2[] fixedPoints = new MappingGridVector2[] {new MappingGridVector2(fixedV1, fixedV1), new MappingGridVector2(fixedV2, fixedV2), new MappingGridVector2(fixedV3, fixedV3), new MappingGridVector2(fixedV4, fixedV4)}; fixedTransform.mapPoints = fixedPoints; GridVector2 movingV1 = new GridVector2(2.5, 2.5); GridVector2 movingV2 = new GridVector2(2.5, -7.5); GridVector2 movingV3 = new GridVector2(-7.5, 2.5); GridVector2 movingV4 = new GridVector2(-8.5, -8.5); //Point four should be removed by the transform MappingGridVector2[] movingPoints = new MappingGridVector2[] {new MappingGridVector2(movingV1, movingV1), new MappingGridVector2(movingV2, movingV2), new MappingGridVector2(movingV3, movingV3), new MappingGridVector2(movingV4, movingV4)}; movingTransform.mapPoints = movingPoints; movingTransform.Add(fixedTransform); MappingGridVector2[] newPoints = movingTransform.mapPoints; Debug.Assert(newPoints[0].ControlPoint.X == 0 && newPoints[0].ControlPoint.Y == 2.5); Debug.Assert(newPoints[1].ControlPoint.X == 2.5 && newPoints[1].ControlPoint.Y == 0); Debug.Assert(newPoints[2].ControlPoint.X == 2.5 && newPoints[2].ControlPoint.Y == 2.5); }
private static MeshTransform ParseMeshTransform(TransformParameters transform, TransformInfo info, double PixelSpacing= 1.0 ) { int NumVariableParameters = transform.variableParameters.Length; Debug.Assert(NumVariableParameters % 4 == 0); int NumPoints = NumVariableParameters / 4; double Left = System.Convert.ToInt32(transform.fixedParameters[3] * PixelSpacing); double Bottom = System.Convert.ToInt32(transform.fixedParameters[4] * PixelSpacing); double ImageWidth = System.Convert.ToInt32(transform.fixedParameters[5] * PixelSpacing); double ImageHeight = System.Convert.ToInt32(transform.fixedParameters[6] * PixelSpacing); MappingGridVector2[] Points = new MappingGridVector2[NumPoints]; for (int iP = 0; iP < NumPoints; iP++) { int iOffset = (iP * 4); GridVector2 Mapped = new GridVector2((transform.variableParameters[iOffset] * ImageWidth) + Left, (transform.variableParameters[iOffset+1] * ImageHeight) + Bottom); GridVector2 Control = new GridVector2(transform.variableParameters[iOffset+2] * PixelSpacing, transform.variableParameters[iOffset+3] * PixelSpacing); Points[iP] = new MappingGridVector2(Control, Mapped); } return new MeshTransform(Points, info); }
private static GridTransform ParseGridTransform(TransformParameters transform, double PixelSpacing, TransformInfo info) { //string filename = System.IO.Path.GetFileName(parts[1]); //string[] fileparts = filename.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); //this.Number = System.Convert.ToInt32(fileparts[1]); int gridWidth = System.Convert.ToInt32(transform.fixedParameters[2] + 1.0); int gridHeight = System.Convert.ToInt32(transform.fixedParameters[1] + 1.0); int ImageWidth = System.Convert.ToInt32(transform.fixedParameters[5] * PixelSpacing); int ImageHeight = System.Convert.ToInt32(transform.fixedParameters[6] * PixelSpacing); GridRectangle MappedBounds = new GridRectangle(0, ImageWidth, 0, ImageHeight); int NumPts = transform.variableParameters.Length / 2; GridVector2[] Points = new GridVector2[NumPts]; // verticies = new VertexPositionNormalTexture[numPts]; Double minX = Double.MaxValue; Double minY = Double.MaxValue; Double maxX = Double.MinValue; Double maxY = Double.MinValue; //Every number in the array is seperated by an empty space in the array for (int i = 0; i < NumPts; i++) { int iPoint = (i * 2); Double x = transform.variableParameters[iPoint] * PixelSpacing; Double y = transform.variableParameters[iPoint+1] * PixelSpacing; Points[i] = new GridVector2(x, y); //Trace.WriteLine(x.ToString() + ", " + y.ToString(), "Geometry"); if (x < minX) minX = x; if (x > maxX) maxX = x; if (y < minY) minY = y; if (y > maxY) maxY = y; } // List<int> indicies = new List<int>(); MappingGridVector2[] mapList = new MappingGridVector2[gridHeight * gridWidth]; List<int> triangleIndicies = new List<int>(); for (int y = 0; y < gridHeight; y++) { for (int x = 0; x < gridWidth; x++) { int i = x + (y * gridWidth); GridVector2 mapPoint = GridTransform.CoordinateFromGridPos(x, y, gridWidth, gridHeight, ImageWidth,ImageHeight); GridVector2 ctrlPoint = Points[i]; MappingGridVector2 gridPoint = new MappingGridVector2(ctrlPoint, mapPoint); mapList[i] = gridPoint; } } for (int y = 0; y < gridHeight - 1; y++) { for (int x = 0; x < gridWidth - 1; x++) { int botLeft = x + (y * gridWidth); int botRight = (x + 1) + (y * gridWidth); int topLeft = x + ((y + 1) * gridWidth); int topRight = (x + 1) + ((y + 1) * gridWidth); int[] triangles = new int[] { botLeft, botRight, topLeft, botRight, topRight, topLeft }; triangleIndicies.AddRange(triangles); } } return new GridTransform(mapList, MappedBounds, gridWidth, gridHeight, info); }
private static GridTransform ParseGridTransform(TransformParameters transform, StosTransformInfo info, float pixelSpacing, int iFixedParameters, int iVariableParameters, GridRectangle ControlBounds, GridRectangle MappedBounds) { //Find the dimensions of the grid MappingGridVector2[] mappings; float MappedWidth = (float)MappedBounds.Width; float MappedHeight = (float)MappedBounds.Height; int gridWidth = System.Convert.ToInt32(transform.fixedParameters[2] + 1.0); int gridHeight = System.Convert.ToInt32(transform.fixedParameters[1] + 1.0); double NumPts = gridHeight * gridWidth; mappings = new MappingGridVector2[gridWidth * gridHeight]; GridVector2[] Points = new GridVector2[System.Convert.ToInt32(NumPts)]; int iPoints = iVariableParameters + 2; for (int i = 0; i < NumPts; i++) { Points[i].X = transform.variableParameters[i*2] * pixelSpacing; Points[i].Y = transform.variableParameters[(i * 2) + 1] * pixelSpacing; } for (int y = 0; y < gridHeight; y++) { int iYOffset = y * gridWidth; for (int x = 0; x < gridWidth; x++) { int i = x + iYOffset; GridVector2 controlPoint = Points[i]; GridVector2 mappedPoint = GridTransform.CoordinateFromGridPos(x, y, gridWidth, gridHeight, MappedWidth, MappedHeight); mappings[i] = new MappingGridVector2(controlPoint, mappedPoint); } } return new GridTransform(mappings, MappedBounds, gridWidth, gridHeight, info); }
public static TransformBase TransformFromPoints(MappingGridVector2[] Points) { return null; }
public RBFTransform(MappingGridVector2[] points, TransformInfo info) : base(points, info) { }
private static ReferencePointBasedTransform ParseTranslateTransform(TransformParameters transform, TransformInfo info) { if (transform == null) throw new ArgumentNullException("transform"); //string filename = System.IO.Path.GetFileName(parts[1]); //Figure out tile size if we haven't already int ImageWidth = System.Convert.ToInt32(transform.fixedParameters[2]) * 2; int ImageHeight = System.Convert.ToInt32(transform.fixedParameters[3]) * 2; double x = transform.variableParameters[0]; double y = transform.variableParameters[1]; GridVector2 ctrlBotLeft = new GridVector2(x, y); GridVector2 ctrlBotRight = new GridVector2(x + ImageWidth, y); GridVector2 ctrlTopLeft = new GridVector2(x, y + ImageHeight); GridVector2 ctrlTopRight = new GridVector2(x + ImageWidth, y + ImageHeight); GridVector2 mapBotLeft = new GridVector2(0, 0); GridVector2 mapBotRight = new GridVector2(ImageWidth, 0); GridVector2 mapTopLeft = new GridVector2(0, ImageHeight); GridVector2 mapTopRight = new GridVector2(ImageWidth, ImageHeight); MappingGridVector2 BotLeft = new MappingGridVector2(ctrlBotLeft, mapBotLeft); MappingGridVector2 BotRight = new MappingGridVector2(ctrlBotRight, mapBotRight); MappingGridVector2 TopLeft = new MappingGridVector2(ctrlTopLeft, mapTopLeft); MappingGridVector2 TopRight = new MappingGridVector2(ctrlTopRight, mapTopRight); MappingGridVector2[] mapPoints = new MappingGridVector2[] { BotLeft, BotRight, TopLeft, TopRight }; return new GridTransform(mapPoints, new GridRectangle(0, ImageWidth, 0, ImageHeight), 2, 2, info); }
public TriangulationViewModel(MappingGridVector2[] mapPoints, int[] triangleIndicies) { this.MapPoints = mapPoints; this.TriangleIndicies = triangleIndicies; }