private float map(float u) {
float targetLength = u * this.arcLengths[(int)this.len];
int low = 0;
int high = (int)this.len;
int index = 0;
while (low < high) {
index = low + ((int)((high - low) / 2.0f) | 0);
if (this.arcLengths[index] < targetLength) {
low = index + 1;
} else {
high = index;
}
}
if(this.arcLengths[index] > targetLength)
index--;
if(index<0)
index = 0;
return (index + (targetLength - arcLengths[index]) / (arcLengths[index + 1] - arcLengths[index])) / this.len;
}