samskivert / pythagoras

A portable library of geometry classes for Java
Apache License 2.0
44 stars 14 forks source link

Can't create an area with an IShape which has ten points #22

Closed paulis closed 11 years ago

paulis commented 11 years ago

Creating a path with ten points (one moveTo and nine lineTos) and passing it to the constructor of an Area throws an exception:

import org.junit.Test;

import pythagoras.f.Area;
import pythagoras.f.Path;

public class BigAreaTest {

    @Test
    public void areaWithPath() {

        Path path = new Path();
        path.moveTo(0f, 0f);
        for (int i = 1;  i <= 8; i++) {
            path.lineTo(2f * i, 3f * i);    
        }
        Area areaWithNinePoints = new Area(path);

        path.reset();
        path.moveTo(0f, 0f);
        for (int i = 1;  i <= 10; i++) {
            path.lineTo(2f * i, 3f * i);    
        }
        Area areaWithElevenPoints = new Area(path);

        path.reset();
        path.moveTo(0f, 0f);
        for (int i = 1;  i <= 9; i++) {
            path.lineTo(2f * i, 3f * i);    
        }

        // ArrayIndexOutOfBoundsException
        Area areaWithTenPoints = new Area(path);
    }

}
samskivert commented 11 years ago

Fixed in 25b09788e3cc18fa71e932f646333dbf05363c2c.