internal static IPolygon2D ConvertTo2D(Polygon3D polygon3D, IMatrix44 lcs) { var pts = polygon3D.Select(pt => { var p = lcs.TransformToLCS(pt); return(new Point(p.X, p.Y)); }); return(new Polygon2D(pts)); }
/// <summary> /// Calculate relative position of point on polyline. /// </summary> /// <param name="region">region</param> /// <param name="point">Point</param> /// <param name="relativeX">Relative Position along local X axis</param> /// <param name="relativeY">Relative Position along local Y axis</param> /// <param name="toleranceLevel">Tolerance Level</param> /// <returns>True if point exist in polyline</returns> public static bool GetRelativePosition(IRegion3D region, IPoint3D point, ref double relativeX, ref double relativeY, double toleranceLevel = MathConstants.ZeroWeak) { IMatrix44 matrix = GeomOperation.GetMatrixPlane(region); IPoint3D pointInLCS = matrix.TransformToLCS(point); if (pointInLCS.Z.IsZero() == false) { return(false); } relativeX = pointInLCS.X; relativeY = pointInLCS.Y; return(true); }
/// <summary> /// Prepaer a point on region from given region and point. /// </summary> /// <param name="matrix">LCS matrix of baseGeometry</param> /// <param name="baseGeometry">IRegion3D</param> /// <param name="point">IPoint3D</param> /// <returns>New IPointOnRegion object</returns> public static IPointOnRegion GetPointOnRegion(IMatrix44 matrix, IRegion3D baseGeometry, IPoint3D point) { if (baseGeometry == null || point == null) { return(null); } if (matrix == null) { matrix = GetMatrixPlane(baseGeometry); } IPoint3D pointInLCS = matrix.TransformToLCS(point); if (pointInLCS.Z.IsZero() == false) { throw new NotSupportedException("Screen point and selected region are not in same plane"); } IPointOnRegion pointOnRegion = new PointOnRegion(baseGeometry, pointInLCS.X, pointInLCS.Y); return(pointOnRegion); }