public void TestInvertedItalicNTSConforming() { var atb = new AffineTransformationBuilder( new Coordinate(0, 0), new Coordinate(50, 0), new Coordinate(0, 100), new Coordinate(0, 0), new Coordinate(50, 0), new Coordinate(20, 100)); var geom = _wktReader.Read(NTS); //Apply italic effect geom = atb.GetTransformation().Transform(geom); Console.WriteLine(geom.AsText()); IGeometry constraint = ((IPolygon)geom).GetInteriorRingN(0); constraint = geom.Factory.CreatePolygon((ILinearRing)constraint, null); constraint = ((IPolygon)constraint.Buffer(-1)).Shell; var coordinates = constraint.Coordinates; coordinates[coordinates.Length - 1].X -= 1e-7; coordinates[coordinates.Length - 1].Y -= 1e-7; constraint = geom.Factory.CreateLineString(coordinates); Console.WriteLine(constraint.AsText()); //Setup var dtb = new ConformingDelaunayTriangulationBuilder { Constraints = constraint }; dtb.SetSites(geom); var result = dtb.GetEdges(geom.Factory); Console.WriteLine(result.AsText()); }
private static AffineTransformation ReadKnotenListe(string file) { int index = 0; var src = new Coordinate[3]; var dst = new Coordinate[3]; using (var sr = new StreamReader(File.OpenRead(file))) { while (!sr.EndOfStream) { string line = sr.ReadLine(); if (string.IsNullOrEmpty(line)) { continue; } if (line.StartsWith("#")) { continue; } src[index] = new Coordinate(double.Parse(line.Substring(15, 11), NumberFormatInfo.InvariantInfo), double.Parse(line.Substring(26, 11), NumberFormatInfo.InvariantInfo)); dst[index] = new Coordinate(double.Parse(line.Substring(37, 11), NumberFormatInfo.InvariantInfo), double.Parse(line.Substring(48, 11), NumberFormatInfo.InvariantInfo)); index++; if (index == 3) { break; } } } var atb = new AffineTransformationBuilder(src[0], src[1], src[2], dst[0], dst[1], dst[2]); return(atb.GetTransformation()); }
private static AffineTransformation CreateAffineTransformation(Envelope env, int offsetX = 0) { int imageRatio = ImageWidth / ImageHeight; double ratio = env.Width / env.Height; if (ratio > imageRatio) { double growHeight = (env.Width / imageRatio - env.Height) / 2; env.ExpandBy(0, growHeight); } else if (ratio < imageRatio) { double growWidth = (env.Height * imageRatio - env.Width) / 2; env.ExpandBy(growWidth, 0); } var s1 = new Coordinate(env.MinX, env.MaxY); var t1 = new Coordinate(offsetX, 0); var s2 = new Coordinate(env.MaxX, env.MaxY); var t2 = new Coordinate(offsetX + ImageWidth, 0); var s3 = new Coordinate(env.MaxX, env.MinY); var t3 = new Coordinate(offsetX + ImageWidth, ImageHeight); var atb = new AffineTransformationBuilder(s1, s2, s3, t1, t2, t3); return(atb.GetTransformation()); }
static void Run(double p0x, double p0y, double p1x, double p1y, double p2x, double p2y, double pp0x, double pp0y, double pp1x, double pp1y, double pp2x, double pp2y ) { var p0 = new Coordinate(p0x, p0y); var p1 = new Coordinate(p1x, p1y); var p2 = new Coordinate(p2x, p2y); var pp0 = new Coordinate(pp0x, pp0y); var pp1 = new Coordinate(pp1x, pp1y); var pp2 = new Coordinate(pp2x, pp2y); var atb = new AffineTransformationBuilder( p0, p1, p2, pp0, pp1, pp2); var trans = atb.GetTransformation(); var dest = new Coordinate(); AssertEqualPoint(pp0, trans.Transform(p0, dest)); AssertEqualPoint(pp1, trans.Transform(p1, dest)); AssertEqualPoint(pp2, trans.Transform(p2, dest)); }
private static void RunTransform(AffineTransformation trans, Coordinate p0, Coordinate p1, Coordinate p2) { var pp0 = trans.Transform(p0, new Coordinate()); var pp1 = trans.Transform(p1, new Coordinate()); var pp2 = trans.Transform(p2, new Coordinate()); var atb = new AffineTransformationBuilder( p0, p1, p2, pp0, pp1, pp2); var atbTrans = atb.GetTransformation(); var dest = new Coordinate(); AssertEqualPoint(pp0, atbTrans.Transform(p0, dest)); AssertEqualPoint(pp1, atbTrans.Transform(p1, dest)); AssertEqualPoint(pp2, atbTrans.Transform(p2, dest)); }
static void RunSingular(double p0x, double p0y, double p1x, double p1y, double p2x, double p2y, double pp0x, double pp0y, double pp1x, double pp1y, double pp2x, double pp2y ) { var p0 = new Coordinate(p0x, p0y); var p1 = new Coordinate(p1x, p1y); var p2 = new Coordinate(p2x, p2y); var pp0 = new Coordinate(pp0x, pp0y); var pp1 = new Coordinate(pp1x, pp1y); var pp2 = new Coordinate(pp2x, pp2y); var atb = new AffineTransformationBuilder( p0, p1, p2, pp0, pp1, pp2); var trans = atb.GetTransformation(); Assert.IsNull(trans); }
public void TestInvertedItalicNTS() { var atb = new AffineTransformationBuilder( new Coordinate(0, 0), new Coordinate(50, 0), new Coordinate(0, 100), new Coordinate(0, 0), new Coordinate(50, 0), new Coordinate(20, 100)); var geom = _wktReader.Read(NTS); //Apply italic effect geom = atb.GetTransformation().Transform(geom); Console.WriteLine(geom.AsText()); //Setup var dtb = new DelaunayTriangulationBuilder(); dtb.SetSites(geom); var result = dtb.GetEdges(geom.Factory); Console.WriteLine(result.AsText()); }