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?()); }
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 Matrix3D GetShapeInsertionTransformation(double ltScaling) { return(Transformation3D.Scaling2D(ltScaling) * Transformation3D.Translation(this.vector2D_0) * Transformation3D.Rotate(this.double_2) * Transformation3D.Scaling2D(this.double_1)); }
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; } } }