/// <summary> /// Find the intersection of the segment with the half-plane and throw away the result if it is contained /// entirely in the boundary of the half-plane. The method name is a little imprecise, but it gets across the /// basic idea. /// </summary> public static Segment2D IntersectWithOpenHalfPlane(this Segment2D segment, HalfPlane2D halfPlane) { var basePointOffset = halfPlane.GetOffsetFromBoundaryTowardInside(segment.BasePoint); var endPointOffset = halfPlane.GetOffsetFromBoundaryTowardInside(segment.EndPoint); var basePointIsInInterior = !(basePointOffset <= Unit.ZeroDistance); var endPointIsInInterior = !(endPointOffset <= Unit.ZeroDistance); if (!basePointIsInInterior && !endPointIsInInterior) { return(null); } var containsBasePointExactly = !(basePointOffset < Unit.ZeroDistance); var containsEndPointExactly = !(endPointOffset < Unit.ZeroDistance); if (containsBasePointExactly && containsEndPointExactly) { return(segment); } var pointOnBoundary = halfPlane.Boundary.PointIntersectionWithLine(segment.AsLine()); return (containsBasePointExactly ? new Segment2D(segment.BasePoint, pointOnBoundary.Value) : new Segment2D(pointOnBoundary.Value, segment.EndPoint)); }
public HalfPlane2D GetStarboardSide() => HalfPlane2D.FromDirectionAndBoundaryPoint(Direction.RotateReverseQuarterTurn(), BasePoint);
/// <summary> /// Construct the line perpendicular to <paramref name="offsetDirection"/> through /// <paramref name="pointOnLine"/>. /// </summary> public BoundaryLine2D(Direction2D offsetDirection, Point2D pointOnLine) : this(HalfPlane2D.FromDirectionAndBoundaryPoint(offsetDirection, pointOnLine)) { }
public HalfPlane2D GetPortSide() => HalfPlane2D.FromDirectionAndBoundaryPoint(Direction.RotateQuarterTurn(), BasePoint);
public BoundaryLine2D([NotNull] HalfPlane2D halfPlane) { HalfPlane = halfPlane; }