Exemple #1
0
        public static Postion2D RandomPostionInBounds(Paultangle rectangle)
        {
            double x = Random.NextDouble() * (rectangle.Right - rectangle.Left) + rectangle.Left;
            double y = Random.NextDouble() * (rectangle.Bottom - rectangle.Top) + rectangle.Top;

            return(new Postion2D(x, y));
        }
Exemple #2
0
        public static bool Check(Paultangle a, Paultangle b, CheckType type, bool inside)
        {
            CheckCon d;

            switch (type)
            {
            case CheckType.Contains:
                d = new CheckCon(Utils.AInsideB);
                break;

            case CheckType.Overlapping:
                d = new CheckCon(Utils.AOverlapB);
                break;

            default:
                throw new NotImplementedException();
            }

            bool result;

            if (inside)
            {
                result = d(a, b);
            }
            else
            {
                result = !d(a, b);
            }

            return(result);
        }
Exemple #3
0
        public static Paultangle RandomPostionInBounds(Paultangle bounds, Paultangle paultangle)
        {
            do
            {
                paultangle.Postion2D = RandomPostionInBounds(bounds);
            } while (!AInsideB(paultangle, bounds));

            return(paultangle);
        }
Exemple #4
0
        public bool Intersects(Paultangle other)
        {
            Paultangle RectA = this;
            Paultangle RectB = other;

            return(RectA.X1 < RectB.X2 &&
                   RectA.X2 > RectB.X1 &&
                   RectA.Y1 < RectB.Y2 &&
                   RectA.Y2 > RectB.Y1);
        }
Exemple #5
0
 public static bool AOverlapB(Paultangle a, Paultangle b)
 {
     return(a.Intersects(b));
 }
Exemple #6
0
        public static bool AInsideB(Paultangle a, Paultangle b)
        {
            bool result = a.Right <b.Right && a.Left> b.Left && a.Top >= b.Top && a.Bottom < b.Bottom;

            return(result);
        }
Exemple #7
0
 public Paultangle(Paultangle paultangle) : this(paultangle.Postion2D, paultangle.Width, paultangle.Height)
 {
 }
Exemple #8
0
 public Postion2D Calcaute(Paultangle bounds, Postion2D size)
 {
     return new Postion2D(0, Math.Floor(bounds.Height / 2) - Math.Floor(size.Y / 2));
 }
Exemple #9
0
 public Postion2D Calcaute(Paultangle bounds, Postion2D size)
 {
     return(new Postion2D((bounds.Width / 2) - (size.X / 2), 0));
 }