Loading...
Searching...
No Matches
GeometryUtils Class Referenceabstract

A set of functions for working with geometries. More...

Inherits Finalizable.

Static Public Member Functions

static double distanceBetweenGlobalPoints (GlobalPoint from, GlobalPoint to)
 Get distance between GPS points.
 
static double distanceBetweenPoints (Point from, Point to)
 Get distance between points.
 
static double segmentLength (Segment segment)
 Get length of segment.
 
static double polygonArea (Polygon polygon)
 Get polygon area.
 
static Point polygonCenter (Polygon polygon)
 Get polygon geometric center.
 
static bool polygonContainsPoint (Polygon polygon, Point point)
 Checks that polygon contains point.
 
static double segmentPointDistance (Segment segment, Point point)
 Get distance from segment to point.
 
static bool segmentIntersectsSegment (Segment segment1, Segment segment2)
 Checks the intersection of two segments.
 
static Point segmentIntersectionSegment (Segment segment1, Segment segment2)
 Calculate the intersection point of two segments.
 
static double divisionRatioBySegment (Segment segment1, Segment segment2)
 Calculate the division ratio of a segment by a given segment(if intersects)
 
static Point getRatioPoint (Segment segment, double r)
 Calculate projection point on a segment.
 
static double getProjectionRatio (Segment segment, Point point)
 Calculate the division ratio of a segment by a given point Calculate projection point on a segment.
 

Detailed Description

A set of functions for working with geometries.

Definition at line 23 of file geometry_utils.dart.

Member Function Documentation

◆ distanceBetweenGlobalPoints()

static double GeometryUtils.distanceBetweenGlobalPoints ( GlobalPoint from,
GlobalPoint to )
static

Get distance between GPS points.

Parameters
fromstart point of calculation GlobalPoint
toend point of calculation GlobalPoint
Returns
distance in meters

Dart code snippet:

// Calculate distance between global points
double globalDistance = GeometryUtils.distanceBetweenGlobalPoints(globalPoint1, globalPoint2);
print("Distance between Moscow and St. Petersburg: ${globalDistance.toStringAsFixed(2)} meters");

◆ distanceBetweenPoints()

static double GeometryUtils.distanceBetweenPoints ( Point from,
Point to )
static

Get distance between points.

Parameters
fromstart point of calculation Point
toend point of calculation Point
Returns
distance in meters

Dart code snippet:

// Calculate distance between points
double distance = GeometryUtils.distanceBetweenPoints(point1, point2);
print("Distance between P1 and P2: ${distance.toStringAsFixed(2)} meters");

◆ divisionRatioBySegment()

static double GeometryUtils.divisionRatioBySegment ( Segment segment1,
Segment segment2 )
static

Calculate the division ratio of a segment by a given segment(if intersects)

Parameters
segment1first segment of calculation Segment
segment2second segment of calculation Segment
Returns
division ratio

Dart code snippet:

// Calculate division ratio
double divisionRatio = GeometryUtils.divisionRatioBySegment(segment1, segment2);
print("Division ratio: ${divisionRatio.toStringAsFixed(2)}");

◆ getProjectionRatio()

static double GeometryUtils.getProjectionRatio ( Segment segment,
Point point )
static

Calculate the division ratio of a segment by a given point Calculate projection point on a segment.

Parameters
segmentsegment of calculation Segment
pointpoint of calculation Point
Returns
division ratio

Dart code snippet:

// Calculate projection ratio
double projectionRatio = GeometryUtils.getProjectionRatio(segment1, testPoint);
print("Projection ratio: ${projectionRatio.toStringAsFixed(2)}");

◆ getRatioPoint()

static Point GeometryUtils.getRatioPoint ( Segment segment,
double r )
static

Calculate projection point on a segment.

Parameters
segmentsegment of calculation Segment
rdivision ratio
Returns
ratio point Point

Dart code snippet:

// Get point at specific ratio
double ratio = 0.5;
Point ratioPoint = GeometryUtils.getRatioPoint(segment1, ratio);
print("Point at ratio $ratio: (${ratioPoint.x.toStringAsFixed(2)}, ${ratioPoint.y.toStringAsFixed(2)})");

◆ polygonArea()

static double GeometryUtils.polygonArea ( Polygon polygon)
static

Get polygon area.

Parameters
polygonpolygon object for calculation Polygon
Returns
area in meters

Dart code snippet:

// Calculate polygon area
double area = GeometryUtils.polygonArea(polygon);
print("Polygon area: ${area.toStringAsFixed(2)} square meters");

◆ polygonCenter()

static Point GeometryUtils.polygonCenter ( Polygon polygon)
static

Get polygon geometric center.

Parameters
polygonpolygon object for calculation Polygon
Returns
center point Point

Dart code snippet:

// Calculate polygon center
Point center = GeometryUtils.polygonCenter(polygon);
print("Polygon center: (${center.x.toStringAsFixed(2)}, ${center.y.toStringAsFixed(2)})");

◆ polygonContainsPoint()

static bool GeometryUtils.polygonContainsPoint ( Polygon polygon,
Point point )
static

Checks that polygon contains point.

Parameters
polygonpolygon object in which looking for contents Polygon
pointchecking point object Point
Returns
contains or not

Dart code snippet:

// Check if polygon contains point
Point insidePoint = Point(5.0, 5.0);
Point outsidePoint = Point(15.0, 15.0);
bool containsInside = GeometryUtils.polygonContainsPoint(polygon, insidePoint);
bool containsOutside = GeometryUtils.polygonContainsPoint(polygon, outsidePoint);
print("Polygon contains inside point: $containsInside");
print("Polygon contains outside point: $containsOutside");

◆ segmentIntersectionSegment()

static Point GeometryUtils.segmentIntersectionSegment ( Segment segment1,
Segment segment2 )
static

Calculate the intersection point of two segments.

Parameters
segment1first segment of calculation Segment
segment2second segment of calculation Segment
Returns
intersection point Point

Dart code snippet:

// Calculate intersection point
Point intersection = GeometryUtils.segmentIntersectionSegment(segment1, segment2);
print("Intersection point: (${intersection.x.toStringAsFixed(2)}, ${intersection.y.toStringAsFixed(2)})");

◆ segmentIntersectsSegment()

static bool GeometryUtils.segmentIntersectsSegment ( Segment segment1,
Segment segment2 )
static

Checks the intersection of two segments.

Parameters
segment1first segment of calculation Segment
segment2second segment of calculation Segment
Returns
intersects or not

Dart code snippet:

// Check if segments intersect
bool intersects = GeometryUtils.segmentIntersectsSegment(segment1, segment2);
print("Segments intersect: $intersects");

◆ segmentLength()

static double GeometryUtils.segmentLength ( Segment segment)
static

Get length of segment.

Parameters
segmentsegment object for calculation Segment
Returns
length in meters

Dart code snippet:

// Calculate segment length
double length1 = GeometryUtils.segmentLength(segment1);
double length2 = GeometryUtils.segmentLength(segment2);
print("Segment1 length: ${length1.toStringAsFixed(2)} meters");
print("Segment2 length: ${length2.toStringAsFixed(2)} meters");

◆ segmentPointDistance()

static double GeometryUtils.segmentPointDistance ( Segment segment,
Point point )
static

Get distance from segment to point.

Parameters
segmentstart segment of calculation Segment
pointend point of calculation Point
Returns
distance in meters

Dart code snippet:

// Calculate distance from segment to point
double distanceToPoint = GeometryUtils.segmentPointDistance(segment1, testPoint);
print("Distance from segment1 to test point: ${distanceToPoint.toStringAsFixed(2)} meters");

The documentation for this class was generated from the following file: