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)); }
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); }
public static Paultangle RandomPostionInBounds(Paultangle bounds, Paultangle paultangle) { do { paultangle.Postion2D = RandomPostionInBounds(bounds); } while (!AInsideB(paultangle, bounds)); return(paultangle); }
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); }
public static bool AOverlapB(Paultangle a, Paultangle b) { return(a.Intersects(b)); }
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); }
public Paultangle(Paultangle paultangle) : this(paultangle.Postion2D, paultangle.Width, paultangle.Height) { }
public Postion2D Calcaute(Paultangle bounds, Postion2D size) { return new Postion2D(0, Math.Floor(bounds.Height / 2) - Math.Floor(size.Y / 2)); }
public Postion2D Calcaute(Paultangle bounds, Postion2D size) { return(new Postion2D((bounds.Width / 2) - (size.X / 2), 0)); }