utils/math
library
Functions
-
centroid(Iterable<LatLng> points)
→ LatLng
-
Calculates the centroid (average average) of a list of
LatLngs.
-
distToSegment(Offset p, Offset v, Offset w)
→ double
-
Calculates the shortest distance from point
p to the segment v-w.
-
metersPerPixel(double lat, double zoom)
→ double
-
Approximates meters per pixel at
lat and zoom.
-
pointInQuad(Offset p, List<Offset> q)
→ bool
-
Checks if point
p is inside the quad defined by q (must be 4 points).
-
pointInQuad4(Offset p, Offset p1, Offset p2, Offset p3, Offset p4)
→ bool
-
Checks if point
p is inside the quad defined by p1, p2, p3, p4.
Optimized version without list allocation.
-
pointInTri(Offset p, Offset a, Offset b, Offset c)
→ bool
-
Checks if point
p is inside the triangle defined by a, b, c.
-
signedArea(List<Offset> poly)
→ double
-
Calculates the signed area of a polygon defined by
poly.
-
signedArea4(Offset p1, Offset p2, Offset p3, Offset p4)
→ double
-
Calculates the signed area of a 4-point polygon (quad).
Optimized version without list allocation.
-
snap(double v, double step)
→ double
-
Snaps value
v to the nearest multiple of step.