aboutsummaryrefslogtreecommitdiff
path: root/V3/Ellipse.cs
blob: 076aff0541e5042c11edbd5a9dab4ab042b48b89 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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;
        }
    }
}