diff options
author | Thomas Leyh <leyh.thomas@web.de> | 2016-07-24 08:14:18 +0200 |
---|---|---|
committer | Thomas Leyh <leyh.thomas@web.de> | 2016-07-24 08:14:18 +0200 |
commit | ced3d03bdb3ce866d832e03fb212865140905a9a (patch) | |
tree | 2a16c2063a46d3c354ce1585029dda3124f6ad93 /V3/Ellipse.cs | |
parent | 0394dccaf06e1009e591a6ff4d645895574724c1 (diff) | |
download | V3-ced3d03bdb3ce866d832e03fb212865140905a9a.tar.gz V3-ced3d03bdb3ce866d832e03fb212865140905a9a.tar.bz2 |
Diffstat (limited to 'V3/Ellipse.cs')
-rw-r--r-- | V3/Ellipse.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/V3/Ellipse.cs b/V3/Ellipse.cs new file mode 100644 index 0000000..076aff0 --- /dev/null +++ b/V3/Ellipse.cs @@ -0,0 +1,31 @@ +using System; +using Microsoft.Xna.Framework; + +namespace V3 +{ + public struct Ellipse + { + private Vector2 Center { get; } + private float Width { get; } + private float Height { get; } + + public Rectangle BoundaryRectangle => new Rectangle((Center - new Vector2(Width / 2, Height / 2)).ToPoint(), new Vector2(Width, Height).ToPoint()); + + internal Ellipse(Vector2 center, float width, float height) + { + Center = center; + Width = width; + Height = height; + } + + internal bool Contains(Vector2 position) + { + if (Math.Pow(position.X - Center.X, 2) / Math.Pow(Width/2, 2) + + Math.Pow(position.Y - Center.Y, 2) / Math.Pow(Height/2, 2) <= 1) + { + return true; + } + return false; + } + } +} |