Class GeometryExtensions
Extension class to Geometry.
public static class GeometryExtensions
- Inheritance
-
GeometryExtensions
- Inherited Members
Methods
Add(PdfPoint, PdfPoint)
Get a point with the summed coordinates of both points.
public static PdfPoint Add(this PdfPoint point1, PdfPoint point2)
Parameters
Returns
Contains(PdfLine, PdfPoint)
Whether the point is located on the line segment.
public static bool Contains(this PdfLine line, PdfPoint point)
Parameters
Returns
Contains(PdfRectangle, PdfPoint, bool)
Whether the point is located inside the rectangle.
public static bool Contains(this PdfRectangle rectangle, PdfPoint point, bool includeBorder = false)
Parameters
rectangle
PdfRectangleThe rectangle that should contain the point.
point
PdfPointThe point that should be contained within the rectangle.
includeBorder
boolIf set to false, will return false if the point belongs to the border.
Returns
Contains(PdfRectangle, PdfRectangle, bool)
Whether the other rectangle is located inside the rectangle.
public static bool Contains(this PdfRectangle rectangle, PdfRectangle other, bool includeBorder = false)
Parameters
rectangle
PdfRectangleThe rectangle that should contain the other rectangle.
other
PdfRectangleThe other rectangle that should be contained within the rectangle.
includeBorder
boolIf set to false, will return false if the rectangles share side(s).
Returns
Contains(PdfSubpath, PdfPoint, bool)
Whether the point is located inside the subpath.
Ignores winding rule.
public static bool Contains(this PdfSubpath subpath, PdfPoint point, bool includeBorder = false)
Parameters
subpath
PdfSubpathThe subpath that should contain the point.
point
PdfPointThe point that should be contained within the subpath.
includeBorder
boolIf set to false, will return false if the point belongs to the subpath's border.
Returns
Contains(PdfSubpath, PdfRectangle, bool)
Whether the rectangle is located inside the subpath.
Ignores winding rule.
public static bool Contains(this PdfSubpath subpath, PdfRectangle rectangle, bool includeBorder = false)
Parameters
subpath
PdfSubpathThe subpath that should contain the rectangle.
rectangle
PdfRectangleThe rectangle that should be contained within the subpath.
includeBorder
boolIf set to false, will return false if the rectangle is on the subpath's border.
Returns
Contains(PdfSubpath, PdfSubpath, bool)
Whether the other subpath is located inside the subpath.
Ignores winding rule.
public static bool Contains(this PdfSubpath subpath, PdfSubpath other, bool includeBorder = false)
Parameters
subpath
PdfSubpathThe subpath that should contain the rectangle.
other
PdfSubpathThe other subpath that should be contained within the subpath.
includeBorder
boolIf set to false, will return false if the other subpath is on the subpath's border.
Returns
Contains(Line, PdfPoint)
Whether the point is located on the line segment.
public static bool Contains(this PdfSubpath.Line line, PdfPoint point)
Parameters
line
PdfSubpath.Linepoint
PdfPoint
Returns
Contains(PdfPath, PdfPoint, bool)
Whether the point is located inside the path.
public static bool Contains(this PdfPath path, PdfPoint point, bool includeBorder = false)
Parameters
path
PdfPathThe path that should contain the point.
point
PdfPointThe point that should be contained within the path.
includeBorder
boolIf set to false, will return false if the point belongs to the path's border.
Returns
Contains(PdfPath, PdfRectangle, bool)
Whether the rectangle is located inside the path.
public static bool Contains(this PdfPath path, PdfRectangle rectangle, bool includeBorder = false)
Parameters
path
PdfPathThe path that should contain the rectangle.
rectangle
PdfRectangleThe rectangle that should be contained within the path.
includeBorder
boolIf set to false, will return false if the rectangle is on the path's border.
Returns
Contains(PdfPath, PdfSubpath, bool)
Whether the subpath is located inside the path.
public static bool Contains(this PdfPath path, PdfSubpath subpath, bool includeBorder = false)
Parameters
path
PdfPathThe path that should contain the subpath.
subpath
PdfSubpathThe subpath that should be contained within the path.
includeBorder
boolIf set to false, will return false if the subpath is on the path's border.
Returns
Contains(PdfPath, PdfPath, bool)
Whether the other path is located inside the path.
public static bool Contains(this PdfPath path, PdfPath other, bool includeBorder = false)
Parameters
path
PdfPathThe path that should contain the path.
other
PdfPathThe other path that should be contained within the path.
includeBorder
boolIf set to false, will return false if the other subpath is on the path's border.
Returns
DotProduct(PdfPoint, PdfPoint)
Get the dot product of both points.
public static double DotProduct(this PdfPoint point1, PdfPoint point2)
Parameters
Returns
GetArea(PdfPath)
Get the area of the path.
public static double GetArea(this PdfPath path)
Parameters
path
PdfPath
Returns
GrahamScan(IEnumerable<PdfPoint>)
Algorithm to find the convex hull of the set of points with time complexity O(n log n).
public static IEnumerable<PdfPoint> GrahamScan(IEnumerable<PdfPoint> points)
Parameters
points
IEnumerable<PdfPoint>
Returns
Intersect(PdfLine, PdfLine)
Get the PdfPoint that is the intersection of two lines.
public static PdfPoint? Intersect(this PdfLine line, PdfLine other)
Parameters
Returns
Intersect(PdfLine, PdfRectangle)
Gets the PdfLine that is the intersection of the rectangle and the line.
public static PdfLine? Intersect(this PdfLine line, PdfRectangle rectangle)
Parameters
line
PdfLinerectangle
PdfRectangle
Returns
Intersect(PdfLine, Line)
Get the PdfPoint that is the intersection of two lines.
public static PdfPoint? Intersect(this PdfLine line, PdfSubpath.Line other)
Parameters
line
PdfLineother
PdfSubpath.Line
Returns
Intersect(PdfRectangle, List<PdfLine>)
Gets the list of PdfLines that are the intersection of the rectangle and the lines.
public static List<PdfLine> Intersect(this PdfRectangle rectangle, List<PdfLine> lines)
Parameters
rectangle
PdfRectanglelines
List<PdfLine>
Returns
Intersect(PdfRectangle, PdfLine)
Gets the PdfLine that is the intersection of the rectangle and the line.
public static PdfLine? Intersect(this PdfRectangle rectangle, PdfLine line)
Parameters
rectangle
PdfRectangleline
PdfLine
Returns
Intersect(PdfRectangle, PdfRectangle)
Gets the PdfRectangle that is the intersection of two rectangles.
Only works for axis-aligned rectangles.
public static PdfRectangle? Intersect(this PdfRectangle rectangle, PdfRectangle other)
Parameters
rectangle
PdfRectangleother
PdfRectangle
Returns
Intersect(BezierCurve, PdfLine)
Get the PdfPoints that are the intersections of the line and the curve.
public static PdfPoint[] Intersect(this PdfSubpath.BezierCurve bezierCurve, PdfLine line)
Parameters
bezierCurve
PdfSubpath.BezierCurveline
PdfLine
Returns
- PdfPoint[]
Intersect(BezierCurve, Line)
Get the PdfPoints that are the intersections of the line and the curve.
public static PdfPoint[] Intersect(this PdfSubpath.BezierCurve bezierCurve, PdfSubpath.Line line)
Parameters
bezierCurve
PdfSubpath.BezierCurveline
PdfSubpath.Line
Returns
- PdfPoint[]
Intersect(Line, PdfLine)
Get the PdfPoint that is the intersection of two lines.
public static PdfPoint? Intersect(this PdfSubpath.Line line, PdfLine other)
Parameters
line
PdfSubpath.Lineother
PdfLine
Returns
Intersect(Line, Line)
Get the PdfPoint that is the intersection of two lines.
public static PdfPoint? Intersect(this PdfSubpath.Line line, PdfSubpath.Line other)
Parameters
line
PdfSubpath.Lineother
PdfSubpath.Line
Returns
IntersectT(BezierCurve, PdfLine)
Get the t values that are the intersections of the line and the curve.
public static double[] IntersectT(this PdfSubpath.BezierCurve bezierCurve, PdfLine line)
Parameters
bezierCurve
PdfSubpath.BezierCurveline
PdfLine
Returns
- double[]
List of t values where the PdfSubpath.BezierCurve and the PdfLine intersect.
IntersectT(BezierCurve, Line)
Get the t values that are the intersections of the line and the curve.
public static double[] IntersectT(this PdfSubpath.BezierCurve bezierCurve, PdfSubpath.Line line)
Parameters
bezierCurve
PdfSubpath.BezierCurveline
PdfSubpath.Line
Returns
- double[]
List of t values where the PdfSubpath.BezierCurve and the PdfSubpath.Line intersect.
IntersectsWith(PdfLine, PdfLine)
Whether two lines intersect.
public static bool IntersectsWith(this PdfLine line, PdfLine other)
Parameters
Returns
IntersectsWith(PdfLine, PdfRectangle)
Whether the rectangle and the line intersect.
public static bool IntersectsWith(this PdfLine line, PdfRectangle rectangle)
Parameters
line
PdfLinerectangle
PdfRectangle
Returns
IntersectsWith(PdfLine, Line)
Whether two lines intersect.
public static bool IntersectsWith(this PdfLine line, PdfSubpath.Line other)
Parameters
line
PdfLineother
PdfSubpath.Line
Returns
IntersectsWith(PdfPoint, PdfPoint, PdfPoint, PdfPoint)
Whether the line formed by p11
and p12
intersects the line formed by p21
and p22
.
public static bool IntersectsWith(PdfPoint p11, PdfPoint p12, PdfPoint p21, PdfPoint p22)
Parameters
Returns
IntersectsWith(PdfRectangle, PdfLine)
Whether the rectangle and the line intersect.
public static bool IntersectsWith(this PdfRectangle rectangle, PdfLine line)
Parameters
rectangle
PdfRectangleline
PdfLine
Returns
IntersectsWith(PdfRectangle, PdfPoint, PdfPoint)
Whether the line formed by pl1
and pl2
intersects the rectangle.
public static bool IntersectsWith(PdfRectangle rectangle, PdfPoint pl1, PdfPoint pl2)
Parameters
rectangle
PdfRectanglepl1
PdfPointpl2
PdfPoint
Returns
IntersectsWith(PdfRectangle, PdfRectangle)
Whether two rectangles overlap.
Returns false if the two rectangles only share a border.
public static bool IntersectsWith(this PdfRectangle rectangle, PdfRectangle other)
Parameters
rectangle
PdfRectangleother
PdfRectangle
Returns
IntersectsWith(BezierCurve, PdfLine)
Checks if the curve and the line are intersecting.
Avoid using this method as it is not optimised. Use Intersect(BezierCurve, PdfLine) instead.
public static bool IntersectsWith(this PdfSubpath.BezierCurve bezierCurve, PdfLine line)
Parameters
bezierCurve
PdfSubpath.BezierCurveline
PdfLine
Returns
IntersectsWith(BezierCurve, Line)
Checks if the curve and the line are intersecting.
Avoid using this method as it is not optimised. Use Intersect(BezierCurve, Line) instead.
public static bool IntersectsWith(this PdfSubpath.BezierCurve bezierCurve, PdfSubpath.Line line)
Parameters
bezierCurve
PdfSubpath.BezierCurveline
PdfSubpath.Line
Returns
IntersectsWith(Line, PdfLine)
Whether two lines intersect.
public static bool IntersectsWith(this PdfSubpath.Line line, PdfLine other)
Parameters
line
PdfSubpath.Lineother
PdfLine
Returns
IntersectsWith(Line, Line)
Whether two lines intersect.
public static bool IntersectsWith(this PdfSubpath.Line line, PdfSubpath.Line other)
Parameters
line
PdfSubpath.Lineother
PdfSubpath.Line
Returns
MinimumAreaRectangle(IEnumerable<PdfPoint>)
Algorithm to find the (oriented) minimum area rectangle (MAR) by first finding the convex hull of the points and then finding its MAR.
public static PdfRectangle MinimumAreaRectangle(IEnumerable<PdfPoint> points)
Parameters
points
IEnumerable<PdfPoint>The points.
Returns
Normalise(PdfRectangle)
Gets the axis-aligned rectangle that completely containing the original rectangle, with no rotation.
public static PdfRectangle Normalise(this PdfRectangle rectangle)
Parameters
rectangle
PdfRectangle
Returns
OrientedBoundingBox(IReadOnlyList<PdfPoint>)
Algorithm to find the oriented bounding box (OBB) by first fitting a line through the points to get the slope, then rotating the points to obtain the axis-aligned bounding box (AABB), and then rotating back the AABB.
public static PdfRectangle OrientedBoundingBox(IReadOnlyList<PdfPoint> points)
Parameters
points
IReadOnlyList<PdfPoint>The points.
Returns
ParallelTo(PdfLine, PdfLine)
Checks if both lines are parallel.
public static bool ParallelTo(this PdfLine line, PdfLine other)
Parameters
Returns
ParallelTo(PdfLine, Line)
Checks if both lines are parallel.
public static bool ParallelTo(this PdfLine line, PdfSubpath.Line other)
Parameters
line
PdfLineother
PdfSubpath.Line
Returns
ParallelTo(Line, PdfLine)
Checks if both lines are parallel.
public static bool ParallelTo(this PdfSubpath.Line line, PdfLine other)
Parameters
line
PdfSubpath.Lineother
PdfLine
Returns
ParallelTo(Line, Line)
Checks if both lines are parallel.
public static bool ParallelTo(this PdfSubpath.Line line, PdfSubpath.Line other)
Parameters
line
PdfSubpath.Lineother
PdfSubpath.Line
Returns
Split(BezierCurve, double)
Split a bezier curve into 2 bezier curves, at tau.
public static (PdfSubpath.BezierCurve, PdfSubpath.BezierCurve) Split(this PdfSubpath.BezierCurve bezierCurve, double tau)
Parameters
bezierCurve
PdfSubpath.BezierCurveThe original bezier curve.
tau
doubleThe t value were to split the curve, usually between 0 and 1, but not necessary.
Returns
Subtract(PdfPoint, PdfPoint)
Get a point with the substracted coordinates of both points.
public static PdfPoint Subtract(this PdfPoint point1, PdfPoint point2)