note: consider only distinct points as dupes skew xavg.
bool (points):
if points == null:
throw
result = true
distinctpoints = points.distinct()
// xavg using distinct as dupes skew avg
xavg = distinctpoints.avg(p => p.x)
for p in distinctpoints:
if !distinctpoints.has(mirror(p, xavg))
result = false
break
return result
mirror(p, xavg):
return point(xavg + (xavg-p.x), p.y)
No comments:
Post a Comment