Slick Forums
http://slick.ninjacave.com/forum/

BUG: Circle.contains(x, y) doesn't work correctly...
http://slick.ninjacave.com/forum/viewtopic.php?f=1&t=5944
Page 1 of 1

Author:  Metroids [ Wed Dec 05, 2012 5:35 pm ]
Post subject:  BUG: Circle.contains(x, y) doesn't work correctly...

Both of these give wrong results...

System.out.println(new Circle(10, 10, 2).contains(8, 8)); // True
System.out.println(new Circle(10, 10, 2).contains(10, 10)); // False

The code looks like this:

Code:
        return (x - getX()) * (x - getX()) + (y - getY()) * (y - getY()) < getRadius() * getRadius();


I think it should be

Code:
        return (x - getCenterX()) * (x - getCenterX()) + (y - getCenterY()) * (y - getCenterY()) < getRadius() * getRadius();

Author:  jorgenpt [ Mon Jan 21, 2013 6:47 pm ]
Post subject:  Re: BUG: Circle.contains(x, y) doesn't work correctly...

I found this too - I've submitted a pull request that fixes this bug.

https://bitbucket.org/kevglass/slick/pu ... shape/diff

Author:  davedes [ Fri Jan 25, 2013 4:45 pm ]
Post subject:  Re: BUG: Circle.contains(x, y) doesn't work correctly...

Please send pull requests for development branch, not default branch. Thanks. :)

Page 1 of 1 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/