The length of dists is wrong. It should be same as poly.length.
dists need to assign default value 0.
In java double[] dists = new double[n]; will create an array which all item default value is zero (Cause double is primitive type).
In dart final dists = List<num>(0) will create an array which all item default value is null.
There two issue in 'simplify' function.
dists
is wrong. It should be same aspoly.length
.dists
need to assign default value 0. In javadouble[] dists = new double[n];
will create an array which all item default value is zero (Cause double is primitive type). In dartfinal dists = List<num>(0)
will create an array which all item default value is null.