
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;

namespace GoldenEye
{
    public class Selection
    {
        public Selection(Rectangle R)
        {
            _R = R;

            aa = Math.Pow( ((double)_R.Left - (double)_R.Right)/2 , 2);
            bb = Math.Pow(((double)_R.Top - (double)_R.Bottom) / 2, 2);
            cX = Math.Round(((double)_R.Left + (double)_R.Right) / 2);
            cY = Math.Round(((double)_R.Top + (double)_R.Bottom) / 2);

        }

        private double aa;
        private double bb;
        private double cX;
        private double cY;


        private Rectangle _R; public Rectangle R { get { return _R; } }

        public Double Width { get { return (double)_R.Width; } }
        public Double Height { get { return (double)_R.Height; } }


        public Int32 y1 { get { return _R.Top; } }
        public Int32 y2 { get { return _R.Bottom; } }
        public Int32 x1 { get { return _R.Left; } }
        public Int32 x2 { get { return _R.Right; } }


        public Point Center
        {
            get
            {
                return new Point((int)cX, (int)cY);
            }
        }

        public Boolean IsInEllipse(Point p)
        {
            double dx = Math.Pow( p.X -cX, 2);
            double dy = Math.Pow(p.Y - cY, 2);
            double w = dx / aa + dy / bb ;

            if (w <= 1)
                return true;
            else 
                return false;
        }

        


    }
}
