namespace Core.Common.Base.Geometry
{
///
/// Class that captures the intersection calculation result between two
/// instances.
///
public class Segment2DIntersectSegment2DResult
{
private Segment2DIntersectSegment2DResult(Intersection2DType type, Point2D[] points)
{
IntersectionType = type;
IntersectionPoints = points;
}
///
/// Gets the type of the intersection found.
///
public Intersection2DType IntersectionType { get; private set; }
///
/// Gets the intersection points, if any.
///
///
/// If has a value of ,
/// the array holds the single intersection points found.
/// If has a value of ,
/// the array holds the two points defining the overlapping area for both segments.
///
public Point2D[] IntersectionPoints { get; private set; }
///
/// Creates the calculation result for having found no intersections.
///
public static Segment2DIntersectSegment2DResult CreateNoIntersectResult()
{
return new Segment2DIntersectSegment2DResult(Intersection2DType.NoIntersections, new Point2D[0]);
}
///
/// Creates the calculation result for having found a single intersection.
///
/// The intersection point.
public static Segment2DIntersectSegment2DResult CreateIntersectionResult(Point2D intersectionPoint)
{
return new Segment2DIntersectSegment2DResult(Intersection2DType.Intersects, new[]
{
intersectionPoint
});
}
///
/// Creates the calculation result for having found an overlap between the two segments.
///
/// The start of the overlapping segment.
/// The end of the overlapping segment.
public static Segment2DIntersectSegment2DResult CreateOverlapResult(Point2D start, Point2D end)
{
return new Segment2DIntersectSegment2DResult(Intersection2DType.Overlapping, new[]
{
start,
end
});
}
}
}