private static Matrix4D?smethod_0(IList <Point3D> points) { if (points.Count < 3) { return(new Matrix4D?()); } Point3D point = points[0]; Vector3D[] vector3DArray = new Vector3D[2]; int num = 0; for (int index = 1; index < points.Count; ++index) { Vector3D v = points[index] - point; if (v.GetLengthSquared() > 0.0) { if (num == 0) { vector3DArray[0] = v; ++num; } else { Vector3D zaxis = Vector3D.CrossProduct(vector3DArray[0], v); double length = zaxis.GetLength(); if (length > 0.0) { zaxis /= length; return(new Matrix4D?(PolylineShape4D.smethod_1(zaxis))); } } } } return(new Matrix4D?()); }
private static Matrix4D smethod_1(Vector3D zaxis) { if (zaxis == Vector3D.ZAxis) { return(Matrix4D.Identity); } zaxis.Normalize(); Vector3D xaxis = System.Math.Abs(zaxis.X) >= 1.0 / 64.0 || System.Math.Abs(zaxis.Y) >= 1.0 / 64.0 ? Vector3D.CrossProduct(Vector3D.ZAxis, zaxis) : Vector3D.CrossProduct(Vector3D.YAxis, zaxis); xaxis.Normalize(); return(PolylineShape4D.smethod_2(xaxis, zaxis)); }
public Class178(PolylineShape4D shape, Matrix4D transform) { this.matrix4D_0 = transform; for (this.ilist_0 = shape.ilist_0; this.int_0 < this.ilist_0.Count; ++this.int_0) { int count = this.ilist_0[this.int_0].Count; if (count > 0) { if (count != 1) { break; } this.ilist_0[this.int_0].Add(this.ilist_0[this.int_0][0]); break; } } }
public FlatShape4D ToFlatShape() { IList <Point3D> points1 = (IList <Point3D>) new List <Point3D>(); foreach (List <Vector4D> vector4DList in (IEnumerable <Polyline4D>) this.ilist_0) { foreach (Vector4D vector4D in vector4DList) { points1.Add(vector4D.ToPoint3D()); Matrix4D?nullable = PolylineShape4D.smethod_0(points1); if (nullable.HasValue) { Matrix4D transpose = nullable.Value.GetTranspose(); Point3D point3D = points1[0]; return(this.method_0(Transformation4D.Translation((Vector3D)point3D) * nullable.Value, transpose * Transformation4D.Translation(-point3D.X, -point3D.Y, -point3D.Z))); } } } if (points1.Count == 0) { return(new FlatShape4D(ShapeTool.NullShape, this.IsFilled)); } HashSet <Point3D> point3DSet = new HashSet <Point3D>((IEnumerable <Point3D>)points1); if (point3DSet.Count == 1) { Point3D point3D = points1[0]; return(this.method_0(Transformation4D.Translation((Vector3D)point3D), Transformation4D.Translation(-point3D.X, -point3D.Y, -point3D.Z))); } IList <Point3D> points2 = (IList <Point3D>) new List <Point3D>((IEnumerable <Point3D>)point3DSet); Vector3D v = points2[1] - points2[0]; v.Normalize(); if (Vector3D.DotProduct(Vector3D.ZAxis, v) != 0.0) { Point3D point3D1 = points2[0]; Point3D point3D2 = points2[0]; if (point3D1.X != point3D2.X) { points2.Add(new Point3D(point3D2.X, point3D2.Y, point3D1.Z)); } else { if (point3D1.Y == point3D2.Y) { return(this.method_0(Transformation4D.Translation((Vector3D)point3D1) * Transformation4D.RotateX(System.Math.PI / 2.0), Transformation4D.RotateX(-1.0 * System.Math.PI / 2.0) * Transformation4D.Translation(-point3D1.X, -point3D1.Y, -point3D1.Z))); } points2.Add(new Point3D(point3D2.X, point3D2.Y, point3D1.Z)); } Matrix4D?nullable = PolylineShape4D.smethod_0(points2); if (!nullable.HasValue) { return(new FlatShape4D(ShapeTool.NullShape, this.IsFilled)); } Matrix4D transpose = nullable.Value.GetTranspose(); Point3D point3D3 = points2[0]; return(this.method_0(Transformation4D.Translation((Vector3D)point3D3) * nullable.Value, transpose * Transformation4D.Translation(-point3D3.X, -point3D3.Y, -point3D3.Z))); } Point3D point3D4 = points2[0]; return(this.method_0(Transformation4D.Translation((Vector3D)point3D4), Transformation4D.Translation(-point3D4.X, -point3D4.Y, -point3D4.Z))); }