if (points.size() >= 3) {
for (int i = 1; i <= points.size() - 1; i++) {
if (Intersector.intersectLines(points.get(0), points.get(1), points.get(i), points.get(i + 1), null)) return true;
}
}
return false;
I cant find my error with this, so it seems like the method intersecLines(), which as you could guess checks if two lines have one or more common points, returns wrong results.
Im using this in a Snake-kind-of game, and this method should check if the line between the first and the second point of this "snake-path" (which is existing as an ArrayList consisting of the points of the path) intersects with one of the other lines, which the snake consists of.
The parameters are: Vector2 first Point of first line; Vector2 second point of first line; Vector2 first point of second line; Vector2 second point of second line; Vector2 that will be set to the intersecting point.
For those of you who are not familiar with GDX, it is a framework used for cross platform development in java, most of the methods are implementations of openGL ES methods. Heres the api reference of the Intersector class: http://libgdx.badlogicgames.com/nightlies/docs/api/com/badlogic/gdx/math/Intersector.html