Skip to content

Commit ca24bce

Browse files
committed
Few bug fixes for Ellipse methods.
1 parent b17744d commit ca24bce

3 files changed

Lines changed: 9 additions & 9 deletions

File tree

src/geom/ellipse/Circumference.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
*/
1111
var Circumference = function (ellipse)
1212
{
13-
var rx = ellipse.width;
14-
var ry = ellipse.height;
13+
var rx = ellipse.width / 2;
14+
var ry = ellipse.height / 2;
1515
var h = Math.pow((rx - ry), 2) / Math.pow((rx + ry), 2);
1616

1717
return (Math.PI * (rx + ry)) * (1 + ((3 * h) / (10 + Math.sqrt(4 - (3 * h)))));

src/geom/ellipse/Contains.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ var Contains = function (ellipse, x, y)
1616
{
1717
return false;
1818
}
19-
19+
2020
// Normalize the coords to an ellipse with center 0,0 and a radius of 0.5
21-
var normx = ((x - ellipse.x) / ellipse.width) - 0.5;
22-
var normy = ((y - ellipse.y) / ellipse.height) - 0.5;
23-
21+
var normx = ((x - ellipse.x) / ellipse.width);
22+
var normy = ((y - ellipse.y) / ellipse.height);
23+
2424
normx *= normx;
2525
normy *= normy;
26-
26+
2727
return (normx + normy < 0.25);
2828
};
2929

src/geom/ellipse/GetBounds.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ var GetBounds = function (ellipse, out)
1515
{
1616
if (out === undefined) { out = new Rectangle(); }
1717

18-
out.x = ellipse.x - ellipse.width;
19-
out.y = ellipse.y - ellipse.height;
18+
out.x = ellipse.left;
19+
out.y = ellipse.top;
2020
out.width = ellipse.width;
2121
out.height = ellipse.height;
2222

0 commit comments

Comments
 (0)