I have a polygon, it has five points like this:

then I add another point to polygon (the red one):

what's the algorithm to determine two polygons is same one (not just angle/length is same, coordinates also same too).
I have a polygon, it has five points like this:

then I add another point to polygon (the red one):

what's the algorithm to determine two polygons is same one (not just angle/length is same, coordinates also same too).
As your same means same shape,size,orientation and position
A={ a0,a1...a(n-1) } and B={ b0,b1,...b(m-1) }for starters I assume you have no oversampling (line is always 2 points not more)
compare m,n
m==n so I will use just n from now onfind (a(i)==b(j)) where i,j=<0,n)
i=0,j=0i=0 and find j with single O(n) loopcompare the points
for (k=0;k<n;k++)
{
if (a(i)!=b(j)) return false; // not the same
i++; if (i>=n) i=0;
j++; if (j>=n) j=0;
} return true; // are the same
if (|a(i)-b(j)|>=max_difference_treshold)1e-6 or 1e-10 valuesFor oversampled polygon you need to resample points of booth A,B first
p(i-1),p(i),p(i+1)d1=p(i)-p(i-1); dx1=p1.x; dy1=p1.y;d2=p(i+1)-p(i); dx2=p2.x; dy2=p2.y;(dx1*dy2==dx1*dy1) then delete p(i) from the set //import turf library
var turf = require('@turf/turf');
// create polygon using turf or you can directly use geoJSON
var polygon1 = turf.polygon(firstPolygonCoordinates);
var polygon2 = turf.polygon(secondPolygonCoordinates);
// Compare two polygon using turf's booleanEqual method
if (turf.booleanEqual(polygon1, polygon2)) {
// Add your logic here
}
Depending on your point of view. Two rectangles may be the same independently of the position.