hapticdata / toxiclibsjs

Toxiclibsjs is a library for computational design tasks with JavaScript. This library is a port of http://toxiclibs.org for java and processing.
http://haptic-data.com/toxiclibsjs
GNU Lesser General Public License v2.1
806 stars 107 forks source link

Ellipse.containsPoint issue #43

Closed trbarrett closed 7 years ago

trbarrett commented 7 years ago

Hi there,

I've been having some troubles with Ellipse.containsPoint today. It doesn't seem to be working in 0.3.2. Same result in the latest of both chrome and firefox.

let ellipse = new toxi.geom.Ellipse(100, 100, 20, 50);
console.log(ellipse.containsPoint(new toxi.geom.Vec2D(100, 100)));
console.log(ellipse.containsPoint(new toxi.geom.Vec2D(110, 110)));
console.log(ellipse.containsPoint(new toxi.geom.Vec2D(90, 90)));
console.log(ellipse.containsPoint(new toxi.geom.Vec2D(100, 60)));

Output:

false
false
false
false

After calling toPolygon2D on that ellipse, and using the poly result the other hand:

let asPoly = ellipse.toPolygon2D(20);
console.log(asPoly.containsPoint(new toxi.geom.Vec2D(100, 100)));
console.log(asPoly.containsPoint(new toxi.geom.Vec2D(110, 110)));
console.log(asPoly.containsPoint(new toxi.geom.Vec2D(90, 90)));
console.log(asPoly.containsPoint(new toxi.geom.Vec2D(100, 60)));

Output:

true
true
true
true