private static Matrix3D?smethod_0(Point2D[] p1, Point2D[] p2) { Matrix3D matrix3D1 = Transformation3D.Translation(-p1[0].X, -p1[0].Y); Matrix3D matrix3D2 = Transformation3D.Translation(-p2[0].X, -p2[0].Y); Point2D point2D1 = matrix3D1.Transform(p1[1]); Point2D point2D2 = matrix3D2.Transform(p2[1]); Matrix3D matrix3D3 = Transformation3D.Rotate(-System.Math.Atan2(point2D1.Y, point2D1.X)); Matrix3D matrix3D4 = Transformation3D.Rotate(-System.Math.Atan2(point2D2.Y, point2D2.X)); Point2D point2D3 = matrix3D3.Transform(matrix3D1.Transform(p1[2])); Point2D point2D4 = matrix3D4.Transform(matrix3D2.Transform(p2[2])); double num = ((Vector2D)point2D2).GetLength() / ((Vector2D)point2D1).GetLength(); Matrix3D matrix3D5; if (point2D3.Y != 0.0) { double m01 = (point2D4.X - num * point2D3.X) / point2D3.Y; matrix3D5 = new Matrix3D(num, m01, 0.0, 0.0, point2D4.Y / point2D3.Y, 0.0, 0.0, 0.0, 1.0); } else { if (point2D3.X == 0.0) { return(new Matrix3D?()); } double m10 = (point2D4.Y - num * point2D3.Y) / point2D3.X; matrix3D5 = new Matrix3D(num, 0.0, 0.0, m10, num, 0.0, 0.0, 0.0, 1.0); } Matrix3D matrix3D6 = Transformation3D.Translation(p2[0].X, p2[0].Y) * Transformation3D.Rotate(System.Math.Atan2(point2D2.Y, point2D2.X)) * matrix3D5 * matrix3D3 * matrix3D1; if ((matrix3D6.Transform(p1[2]) - p2[2]).GetLength() / num < 0.0001) { return(new Matrix3D?(matrix3D6)); } return(new Matrix3D?()); }
public Class472( string text, Interface14 font, Color color, short lineWeight, Interface35[] glyphs, Matrix2D basicTrafo, double charSpacingFactor) { this.string_0 = text; this.interface14_0 = font; this.color_0 = color; this.short_0 = lineWeight; this.interface35_0 = glyphs; this.double_0 = charSpacingFactor; this.matrix2D_0 = basicTrafo; foreach (ICanonicalGlyph glyph in glyphs) { this.vector2D_0 += glyph.Advance; } if (charSpacingFactor != 1.0) { this.vector2D_0.X *= charSpacingFactor; } this.generalShape2D_0 = new GeneralShape2D(); Vector2D zero = Vector2D.Zero; foreach (Interface35 glyph in glyphs) { this.generalShape2D_0.Append(glyph.Path, false, Transformation3D.Translation(zero.X, zero.Y)); zero += glyph.Advance * charSpacingFactor; } }
public void PropagateTo(IScaler scaler, ITranslator translator) { if (!this.ValidForZoom) { return; } Rectangle2D normalizedZoomRectangle = this.NormalizedZoomRectangle; Point2D center = normalizedZoomRectangle.Center; Point2D point = (Transformation3D.Translation(translator.Translation) * Transformation3D.Scaling2D(scaler.ScaleFactor)).GetInverse().Transform(center); double num = 2.0 / System.Math.Max(System.Math.Abs(normalizedZoomRectangle.Width), System.Math.Abs(normalizedZoomRectangle.Height)); scaler.ScaleFactor *= num; Point2D point2D = (Transformation3D.Translation(translator.Translation) * Transformation3D.Scaling2D(scaler.ScaleFactor)).Transform(point); translator.Translation += center - point2D; }
internal void TransformMe(double rotationAngle, double scaling, Vector2D offset) { Matrix3D matrix3D = Transformation3D.Translation(offset) * Transformation3D.Scaling2D(scaling) * Transformation3D.Rotate(rotationAngle); foreach (DxfPattern.Line line in this.list_0) { line.Angle += rotationAngle; line.BasePoint = matrix3D.Transform(line.BasePoint); line.Offset = matrix3D.Transform(line.Offset); for (int index1 = 0; index1 < line.DashLengths.Count; ++index1) { List <double> dashLengths; int index2; (dashLengths = line.DashLengths)[index2 = index1] = dashLengths[index2] * scaling; } } }
private WoutWareGlyph method_4(Stream stream, byte[] buffer) { char letter = WoutWareFont.smethod_5(stream, buffer); Vector2D advance = WoutWareFont.smethod_7(stream, buffer); GeneralShape2D generalShape2D = new GeneralShape2D(); int num; while (true) { num = stream.ReadByte(); if (num >= 0) { WoutWareFont.Enum12 enum12 = (WoutWareFont.Enum12)num; if ((uint)enum12 <= 100U) { switch (enum12) { case WoutWareFont.Enum12.const_5: goto label_11; case WoutWareFont.Enum12.const_4: double m00_1 = (double)WoutWareFont.smethod_3(stream, buffer); double m01 = (double)WoutWareFont.smethod_3(stream, buffer); double m02_1 = (double)WoutWareFont.smethod_3(stream, buffer); double m10 = (double)WoutWareFont.smethod_3(stream, buffer); double m11_1 = (double)WoutWareFont.smethod_3(stream, buffer); double m12_1 = (double)WoutWareFont.smethod_3(stream, buffer); generalShape2D.Append(this.ilist_0[WoutWareFont.smethod_1(stream, buffer)], false, new Matrix3D(m00_1, m01, m02_1, m10, m11_1, m12_1, 0.0, 0.0, 1.0)); continue; case WoutWareFont.Enum12.const_0: generalShape2D.Append(this.ilist_0[WoutWareFont.smethod_1(stream, buffer)], false); continue; default: goto label_12; } } else { switch (enum12) { case WoutWareFont.Enum12.const_3: double m00_2 = (double)WoutWareFont.smethod_3(stream, buffer); double m02_2 = (double)WoutWareFont.smethod_3(stream, buffer); double m11_2 = (double)WoutWareFont.smethod_3(stream, buffer); double m12_2 = (double)WoutWareFont.smethod_3(stream, buffer); generalShape2D.Append(this.ilist_0[WoutWareFont.smethod_1(stream, buffer)], false, new Matrix3D(m00_2, 0.0, m02_2, 0.0, m11_2, m12_2, 0.0, 0.0, 1.0)); continue; case WoutWareFont.Enum12.const_2: double x1 = (double)WoutWareFont.smethod_3(stream, buffer); double y1 = (double)WoutWareFont.smethod_3(stream, buffer); generalShape2D.Append(this.ilist_0[WoutWareFont.smethod_1(stream, buffer)], false, Transformation3D.Scaling(x1, y1)); continue; case WoutWareFont.Enum12.const_1: double x2 = (double)WoutWareFont.smethod_3(stream, buffer); double y2 = (double)WoutWareFont.smethod_3(stream, buffer); generalShape2D.Append(this.ilist_0[WoutWareFont.smethod_1(stream, buffer)], false, Transformation3D.Translation(x2, y2)); continue; default: goto label_12; } } } else { break; } } throw new IOException("Unexpected end of input!"); label_11: IShape2D outline = !generalShape2D.HasSegments ? (IShape2D)NullShape2D.Instance : (IShape2D) new CachedBoundsShape2D((IShape2D)generalShape2D); return(new WoutWareGlyph(letter, outline, advance)); label_12: throw new IOException("Invalid reference operator " + (object)num); }
private static List <Segment2D[]> smethod_8( Polyline2D[] borders, Point2D reference, Vector2D offset, Vector2D direction, double[] dashes, bool fillInterior) { double angle = System.Math.Atan2(direction.Y, direction.X); Matrix3D matrix3D1 = Transformation3D.Rotate(-angle) * Transformation3D.Translation(-reference.X, -reference.Y); Matrix3D matrix3D2 = Transformation3D.Translation(reference.X, reference.Y) * Transformation3D.Rotate(angle); Vector2D vector2D = matrix3D1.Transform(offset); if (vector2D.Y == 0.0) { return(new List <Segment2D[]>()); } if (vector2D.Y < 0.0) { vector2D = -vector2D; } List <Class811.Class818> class818List1 = new List <Class811.Class818>(); double dashPatternLength = 0.0; if (dashes != null) { foreach (double dash in dashes) { dashPatternLength += System.Math.Abs(dash); } } int num1 = 0; int num2 = -1; foreach (Polyline2D border in borders) { int borderId = border.Closed ? num1++ : num2--; for (int index = border.Count - 1; index > 0; --index) { class818List1.Add(new Class811.Class818(borderId, matrix3D1.Transform(border[index]), matrix3D1.Transform(border[index - 1]))); } if (border.Closed && border.Count >= 3) { class818List1.Add(new Class811.Class818(borderId, matrix3D1.Transform(border[0]), matrix3D1.Transform(border[border.Count - 1]))); } } if (class818List1.Count == 0) { return(new List <Segment2D[]>()); } class818List1.Sort((IComparer <Class811.Class818>)Class811.class816_0); List <Class811.Class818> class818List2 = new List <Class811.Class818>(); double y1 = class818List1[0].point2D_0.Y; double num3 = double.NegativeInfinity; foreach (Class811.Class818 class818 in class818List1) { if (class818.point2D_1.Y > num3) { num3 = class818.point2D_1.Y; } } double num4 = System.Math.Ceiling(y1 / vector2D.Y); double x = vector2D.X * num4; double y2 = vector2D.Y * num4; List <Segment2D[]> segment2DArrayList = new List <Segment2D[]>(); for (; y2 <= num3; y2 += vector2D.Y) { while (class818List1.Count > 0 && class818List1[0].point2D_0.Y <= y2) { Class811.Class818 class818 = class818List1[0]; class818List1.RemoveAt(0); if (class818.point2D_1.Y > y2) { class818List2.Add(class818); } } List <Class811.Class819> intersections = new List <Class811.Class819>(); for (int index = class818List2.Count - 1; index >= 0; --index) { Class811.Class818 class818 = class818List2[index]; if (class818.point2D_1.Y <= y2) { class818List2.RemoveAt(index); } else { intersections.Add(class818.method_0(y2)); } } if (intersections.Count >= 2) { intersections.Sort(); if (intersections.Count % 2 != 0) { Class811.smethod_10(intersections); } for (int index = intersections.Count - 1; index > 0; --index) { if (intersections[index].double_0 == intersections[index - 1].double_0) { intersections.RemoveAt(index); intersections.RemoveAt(--index); } } if (intersections.Count > 0) { if (dashPatternLength > 0.0) { List <Pair <double> > mappedDashes = new List <Pair <double> >(); int num5 = intersections.Count / 2; for (int index = 0; index < num5; ++index) { Class811.Class819 class819_1 = intersections[2 * index]; Class811.Class819 class819_2 = intersections[2 * index + 1]; Class811.smethod_9(mappedDashes, x, class819_1.double_0, class819_2.double_0, dashes, dashPatternLength); } if (mappedDashes.Count > 0) { Segment2D[] segment2DArray = new Segment2D[mappedDashes.Count]; for (int index = 0; index < mappedDashes.Count; ++index) { Point2D point1 = new Point2D(mappedDashes[index].First, y2); Point2D point2 = new Point2D(mappedDashes[index].Second, y2); segment2DArray[index] = new Segment2D(matrix3D2.Transform(point1), matrix3D2.Transform(point2)); } segment2DArrayList.Add(segment2DArray); } } else { Segment2D[] segment2DArray = new Segment2D[intersections.Count / 2]; for (int index = 0; index < intersections.Count; index += 2) { Point2D point1 = new Point2D(intersections[index].double_0, y2); Point2D point2 = new Point2D(intersections[index + 1].double_0, y2); segment2DArray[index / 2] = new Segment2D(matrix3D2.Transform(point1), matrix3D2.Transform(point2)); } segment2DArrayList.Add(segment2DArray); } } } x += vector2D.X; } return(segment2DArrayList); }
public void SetWipeoutPolygon(IList <WW.Math.Point2D> polygon) { Bounds2D bounds2D = new Bounds2D(); bounds2D.Update(polygon); this.InsertionPoint = (WW.Math.Point3D)bounds2D.Min; this.XAxis = new Vector3D(bounds2D.Delta.X, 0.0, 0.0); this.YAxis = new Vector3D(0.0, bounds2D.Delta.Y, 0.0); Matrix3D matrix3D = Transformation3D.Scaling(1.0 / this.XAxis.X, -1.0 / this.YAxis.Y, 1.0) * Transformation3D.Translation(WW.Math.Point2D.Zero - bounds2D.Center); this.BoundaryVertices.Clear(); foreach (WW.Math.Point2D point in (IEnumerable <WW.Math.Point2D>)polygon) { this.BoundaryVertices.Add(matrix3D.Transform(point)); } if (this.BoundaryVertices.Count <= 2 || !(this.BoundaryVertices[0] != this.BoundaryVertices[this.BoundaryVertices.Count - 1])) { return; } this.BoundaryVertices.Add(this.BoundaryVertices[0]); }
public static Matrix3D?GetTransformation( IShape2D shape1, IShape2D shape2, double accuracy) { if (!shape1.HasSegments || !shape2.HasSegments) { return(new Matrix3D?()); } ISegment2DIterator iterator1 = shape1.CreateIterator(); ISegment2DIterator iterator2 = shape2.CreateIterator(); if (iterator1.TotalPointCount != iterator2.TotalPointCount || iterator1.TotalSegmentCount != iterator2.TotalSegmentCount) { return(new Matrix3D?()); } if (iterator1.MoveNext() && iterator2.MoveNext()) { Point2D[] point2DArray1 = new Point2D[iterator1.TotalPointCount]; Point2D[] point2DArray2 = new Point2D[iterator2.TotalPointCount]; double num1 = accuracy * accuracy; if (iterator1.Current(point2DArray1, 0) == iterator2.Current(point2DArray2, 0)) { Matrix3D?nullable = new Matrix3D?(); int offset = 1; if (!iterator1.MoveNext() || !iterator2.MoveNext()) { return(new Matrix3D?(Transformation3D.Translation(point2DArray2[0] - point2DArray1[0]))); } do { int num2 = offset; SegmentType segmentType1 = iterator1.Current(point2DArray1, offset); SegmentType segmentType2 = iterator2.Current(point2DArray2, offset); if (segmentType1 == segmentType2) { offset += GeneralShape2D.int_1[(int)segmentType1]; if (!nullable.HasValue && offset >= 3) { nullable = ShapeTool.smethod_0(point2DArray1, point2DArray2); num2 = 3; } if (nullable.HasValue) { int index = num2; while (true) { if (index < offset) { if ((nullable.Value.Transform(point2DArray1[index]) - point2DArray2[index]).GetLengthSquared() <= num1) { ++index; } else { goto label_15; } } else { break; } } } } else { goto label_14; } }while (iterator1.MoveNext() && iterator2.MoveNext()); goto label_16; label_14: return(new Matrix3D?()); label_15: return(new Matrix3D?()); label_16: return(nullable); } } return(new Matrix3D?()); }
public Matrix3D GetShapeInsertionTransformation(double ltScaling) { return(Transformation3D.Scaling2D(ltScaling) * Transformation3D.Translation(this.vector2D_0) * Transformation3D.Rotate(this.double_2) * Transformation3D.Scaling2D(this.double_1)); }