Exemplo n.º 1
0
 /// <summary>Initializes a new instance of the <see cref="BoundingRectangle"/> struct.</summary>
 /// <param name="minX">The lower bound on the X axis.</param>
 /// <param name="minY">The lower bound on the Y axis.</param>
 /// <param name="maxX">The upper bound on the X axis.</param>
 /// <param name="maxY">The upper bound on the Y axis.</param>
 public BoundingRectangle(float minX, float minY, float maxX, float maxY)
 {
     NumberTools.Sort(ref minX, ref maxX, out minX, out maxX);
     NumberTools.Sort(ref minY, ref maxY, out minY, out maxY);
     Max.X = maxX;
     Max.Y = maxY;
     Min.X = minX;
     Min.Y = minY;
 }
Exemplo n.º 2
0
        public void Contains(ref BoundingRectangle rect, out Containment result)
        {
            float   mag;
            Vector2 maxDistance, minDistance;

            Vector2.Subtract(ref rect.Max, ref Center, out maxDistance);
            Vector2.Subtract(ref Center, ref rect.Min, out minDistance);
            NumberTools.Sort(ref minDistance.X, ref maxDistance.X, out minDistance.X, out maxDistance.X);
            NumberTools.Sort(ref minDistance.Y, ref maxDistance.Y, out minDistance.Y, out maxDistance.Y);
            mag = maxDistance.Length();
            if (mag <= Radius)
            {
                result = Containment.Contains;
            }
            else
            {
                mag    = minDistance.Length();
                result = (mag <= Radius) ? Containment.Intersects : Containment.Disjoint;
            }
        }