From ca24bce499673944613cf008383ec2b3f3f79bf5 Mon Sep 17 00:00:00 2001 From: Antriel Date: Wed, 17 Jan 2018 11:43:34 +0100 Subject: [PATCH] Few bug fixes for Ellipse methods. --- src/geom/ellipse/Circumference.js | 4 ++-- src/geom/ellipse/Contains.js | 10 +++++----- src/geom/ellipse/GetBounds.js | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/geom/ellipse/Circumference.js b/src/geom/ellipse/Circumference.js index 598b8db3a..937451a6c 100644 --- a/src/geom/ellipse/Circumference.js +++ b/src/geom/ellipse/Circumference.js @@ -10,8 +10,8 @@ */ var Circumference = function (ellipse) { - var rx = ellipse.width; - var ry = ellipse.height; + var rx = ellipse.width / 2; + var ry = ellipse.height / 2; var h = Math.pow((rx - ry), 2) / Math.pow((rx + ry), 2); return (Math.PI * (rx + ry)) * (1 + ((3 * h) / (10 + Math.sqrt(4 - (3 * h))))); diff --git a/src/geom/ellipse/Contains.js b/src/geom/ellipse/Contains.js index da1c8cf06..39af14c41 100644 --- a/src/geom/ellipse/Contains.js +++ b/src/geom/ellipse/Contains.js @@ -16,14 +16,14 @@ var Contains = function (ellipse, x, y) { return false; } - + // Normalize the coords to an ellipse with center 0,0 and a radius of 0.5 - var normx = ((x - ellipse.x) / ellipse.width) - 0.5; - var normy = ((y - ellipse.y) / ellipse.height) - 0.5; - + var normx = ((x - ellipse.x) / ellipse.width); + var normy = ((y - ellipse.y) / ellipse.height); + normx *= normx; normy *= normy; - + return (normx + normy < 0.25); }; diff --git a/src/geom/ellipse/GetBounds.js b/src/geom/ellipse/GetBounds.js index cfc5b9bd9..9bf380e65 100644 --- a/src/geom/ellipse/GetBounds.js +++ b/src/geom/ellipse/GetBounds.js @@ -15,8 +15,8 @@ var GetBounds = function (ellipse, out) { if (out === undefined) { out = new Rectangle(); } - out.x = ellipse.x - ellipse.width; - out.y = ellipse.y - ellipse.height; + out.x = ellipse.left; + out.y = ellipse.top; out.width = ellipse.width; out.height = ellipse.height;