Skip to content

Latest commit

 

History

History
160 lines (149 loc) · 11 KB

README.md

File metadata and controls

160 lines (149 loc) · 11 KB

GeoPlanarNet

A simple and small.NET library for computational planar geometry. 

The GeoPlanarNet library's primary function is manipulating basic geometrical primitives like points, lines, triangles, and rectangles in 2D space. Implemented both simple (like finding the intersection point of two lines) and complex (like checking if the point in the circle sector) methods. All methods have overloads to work with standart .NET graphics classes: Point, PointF, Rect, RectF.

Because readability and simplicity of the code were the key objectives, speed and robustness were not given top emphasis. Global tolerance property is used for proximity checking, not an exact robust algorithms.

PointGeo:

  • DistanceTo - Get distance between two points;
  • DistanceToLine - Get shortest distance to the line;
  • DistanceToSegment - Get shortest distance from point to the segment;
  • DistanceToRect - Get shortest distance from point to the axis-oriented and given by arbitrary points rectangle;
  • DistanceToCircle - Get shortest distance from the point to the circle;
  • DistanceToTriangle - Get shortest distance from the point to the triangle;
  • DistanceToSurface - Get shortest distance from point to the surface;
  • BelongsToSegment - Check if the point belongs to the segment;
  • BelongsToLine - Check if the point belongs to the line;
  • BelongsToCircle - Check if a point belongs to a circle;
  • BelongsToCircleSector - Check if the point belong to the specific circle sector;
  • BelongsToEllipse - Check if the point belongs to the axis-parallel ellipse;
  • BelongsToEllipseSector - Check if the point belong to the specific axis-parallel ellipse sector;
  • BelongsToTriangle - Check if a point belongs to a triangle;
  • BelongsToRect - Check if the point belongs to the axis-oriented rectangle;
  • BelongsToSurface - Check if a point belongs to the surface;
  • GetClosestPointOnSegment - Find the point on the segment closest to the given one;
  • GetClosestPointOnCircle - Get closest point on the circle to the given point;
  • GetClosestPointOnEllipse - Get closest point on the axis-parallel ellipse to the given point;
  • GetClosestPointOnTriangle - Get closest point on the triangle to the given point;
  • GetClosestPointOnRect - Get closest point on the axis-oriented and given by arbitrary points rectangle to the given point;
  • GetRelativeLocationSimple, GetRelativeLocation - Get the point location relative to a segment;
  • GetRelativeLocationTriangle - Get the point location relative to the triangle;
  • GetRelativeLocationCircle - Get the point location relative to the circle;
  • GetRelativeLocationEllipse - Get the point location relative to the axis-parallel ellipse;
  • GetRelativeLocationRect - Get the point location relative to the axis-oriented and given by arbitrary points rectangle;
  • GetProjectionToLine - Get projection from the point to the line;
  • HasProjectionToSegment - Check if the point has projection to the segment;
  • GetProjectionToSegment - Get projection point to the segment;
  • Equals - Check if two points are equal;
  • IsCollinear - Check if three points are collinear;
  • Rotate - Rotate the point around the center point;
  • GetVectorProduct - Calculate vector product between point and segment;
  • GetAngle - Get axis-degree angle between two points;
  • MinDistanceToCurveLine - Find the minimal distance from a curve to a point.

SegmentGeo

  • Length - Get segment length;
  • DistanceToPoint - Get shortest distance from point to the segment;
  • DistanceToCircle - Get shortest distance from the segment to the circle;
  • HasIntersection - Check if two segments have intersection;
  • FindIntersection - Find the intersection point between two segments;
  • HasSurfaceIntersection - Check if the curve line and the segment has intersection;
  • FindSurfaceIntersection - Find the intersection point between the segment and the surface;
  • HasRectIntersection - Check if the rectangle and the segment has intersection;
  • FindRectIntersection - Find the intersection point between the rectangle and the surface;
  • HasTriangleIntersection - Check if the triangle and the segment has intersection;
  • FindTriangleIntersection - Find the intersection point between the triangle and the surface;
  • BelongsToLine - Check if the segment belongs to the line;
  • GetXAngleRadians - Get the segment tilt angle relative to the X axis;
  • GetAngleRadians - Get angle between two segments. Get angle between two segments with the common point;
  • IsBetweenAngles - Check if the segment lays between start angle and end angle;
  • GetPointAwayFromStart - Get the point away from the segment start point on the specified distance;
  • GetPointAwayFromEnd - Get the point away from the segment end point on the specified distance;
  • Split - Split the segment to small parts by the segments length;
  • LinearInterpolation - Linear interpolation for point on the segment;
  • LinearInterpolationByStep - Linear interpolation with specified step;
  • IsParallel - Check if two segments are parallel;
  • GetRelativeLocationTriangle - Get the segment location relative to the triangle;
  • CreateFromLine - Cut the line to the segment by X bounds;
  • HasPointProjection - Check if the point has projection to the segment;
  • GetPointProjection - Get projection point to the segment;
  • Contains - Check if the segment contains the point.

LineGeo

  • DistanceToCircle - Get shortest distance from the line to the circle;
  • DistanceToPoint - Get shortest distance to the point;
  • HasIntersection - Check if two lines have intersection;
  • FindIntersection - Find the intersection point between two lines;
  • HasCircleIntersection - Check if the line and the circle has intersection;
  • FindCircleIntersection - Find intersection between the line and the circle;
  • IsParallel - Check if two lines are parallel;
  • Contains - Check if the line contains the point;
  • ContainsSegment - Check if the line contains the segment;
  • FindSlopeKoef - Get coefficients of line linear function K and B;
  • CutByXBounds - Cut the line to the segment by X bounds;
  • GetRelativeLocationCircle - Get the line location relative to the circle;
  • GetPointProjection - Get projection from the point to the line.

CurveLineGeo

  • Length - Get curve length;
  • MinDistanceToPoint - Find the minimal distance from the curve to the point;
  • Split - Split the curve line to small parts by the segments length;
  • HasIntersection - Check if the curve line and the segment has intersection;
  • FindIntersection - Find the intersection point between the segment and the surface.

CircleGeo

  • GetArea - Get the circle area;
  • GetEdgePoint - Get the point on the circle edge on the specified angle;
  • GetAABB - Get the bounding rect of the circle;
  • IsOrthogonal - Check if two circles are orthogonal;
  • HasOverlapping - Check if two circles has overlapping;
  • GetRelativeLocationLine - Get the line location relative to the circle;
  • DistanceToPoint - Get shortest distance from the point to the circle;
  • DistanceToSegment - Get shortest distance from the segment to the circle;
  • DistanceToLine - Get shortest distance from the line to the circle;
  • DistanceToCircle - Get shortest distance from the circle to the circle;
  • DistanceToTriangle - Get shortest distance from the circle to the triangle;
  • HasLineIntersection - Check if the line and the circle have intersection;
  • FindLineIntersection - Find the intersection point between the line and the circle;
  • HasRectIntersection - Check if the circle has intersection with the rectangle;
  • Contains - Check if the circle/circle sector contains the point.

EllipseGeo

  • GetArea - Get the ellipse area;
  • GetEccentricity - Get the ellipse eccentricity;
  • GetPerimeter - Get the ellipse perimeter;
  • Contains - Check if the axis-parallel ellipse/ellipse sector contains the point.

TriangleGeo

  • Area - Get the triangle area;
  • Perimeter - Get the triangle perimeter;
  • GetTriangleType - Get the triangle type;
  • GetAngles - Get the triangle angles;
  • IsRight - Check if one angle is equal 90 degrees;
  • IsObtuse - Check if one angle is greater than 90 degrees;
  • IsAcute - Check if all angles are less than 90 degrees;
  • GetAABB - Get the AABB rect of the triangle;
  • Rotate - Rotate the triangle around the point/the center;
  • GetCenter - Get average center of the triangle;
  • DistanceToPoint - Get shortest distance from the point to the triangle;
  • DistanceToCircle - Get shortest distance from the circle to the triangle;
  • HasSegmentIntersection - Check if has intersection between the segment and the triangle;
  • FindSegmentIntersection - Find the intersection point between the segment and the triangle;
  • GetRelativeLocationSegment - Get the segment location relative to the triangle;
  • Contains - Check if the triangle contains the point.

RectGeo

  • GetArea - Get area of the rectangle;
  • GetCenter - Get the center point of the rectangle;
  • GetDimensions - Get width/height of the rectangle;
  • GetPoints - Get points of the rectangle based on diagonal 0-2 points;
  • GetAABB - Get the AABB rectangle;
  • HasCircleIntersection - Check if the circle has intersection with the axis-oriented and given by arbitrary points rectangle;
  • HasSegmentIntersection - Check if the segment has intersection with the axis-oriented and given by arbitrary points rectangle;
  • FindSegmentIntersection - Find intersection between the segment and the axis-oriented and given by arbitrary points rectangle;
  • CreateFromSegment - Get the rectangle with one side equal to segment;
  • DistanceToPoint - Get shortest distance from point to the axis-oriented and given by arbitrary points rectangle;
  • Contains - Check if the axis-oriented and given by arbitrary points rectangle contains the point.

SurfaceGeo

  • GetArea - Get the surface area;
  • GetMinPoint - Get the minimum point of the surface;
  • GetMaxPoint - Get the maximum point of the surface;
  • GetCenterPoint - Get the surface center point;
  • GetAABB - Get the rectangle covering the entire surface;
  • DistanceToPoint - Get shortest distance from the surface to the point;
  • Contains - Check if the surface contains the point.

GeoPlanarNet

  • Epsilon - tolerance used for comparison operations (default 1e-3);
  • AboutEquals - Check if two floating-point numbers are equal;
  • AboutZero - Check if floating-point number is equal to zero.