示例#1
0
        public BBox Intersection(BBox other)
        {
            var x0 = Math.Max(Left, other.Left);
            var y0 = Math.Max(Bottom, other.Bottom);
            var x1 = Math.Min(Right, other.Right);
            var y1 = Math.Min(Top, other.Top);

            if (x0 <= x1 && y0 <= y1)
            {
                return(new BBox(x0, y0, x1, y1));
            }
            else
            {
                return(null);
            }
        }
示例#2
0
        // BUGGO: Yikes this suddenly broke dramatically when I re-ordered the
        // constructor arguments for BBox's.  I thought I fixed all the instances
        // where that mattered though!
        public override Intersection IntersectBBox(BBox other)
        {
            var intersectionBBox = bbox.Intersection(other);

            if (intersectionBBox == null)
            {
                return(null);
            }
            var contact = intersectionBBox.Center();
            // XXX: rather kludgy and approximate; should take into account starting velocity, etc.
            var dx0        = contact.X - other.Left;
            var dx1        = other.Right - contact.X;
            var dx         = Math.Min(dx0, dx1);
            var xside      = dx0 < dx1 ? -Vector2d.UnitX : Vector2d.UnitX;
            var dy0        = contact.Y - other.Bottom;
            var dy1        = other.Top - contact.Y;
            var dy         = Math.Min(dy0, dy1);
            var yside      = dy0 < dy1 ? Vector2d.UnitY : -Vector2d.UnitY;
            var ds         = Math.Min(dx, dy);
            var sideNormal = dx < dy ? xside : yside;
            var flat       = dx < dy ? intersectionBBox.Dy : intersectionBBox.Dx;

            return(new Intersection(contact, sideNormal, 0.5 * ds, -0.5 * ds, flat, -flat));
        }
示例#3
0
 public bool IntersectsBBox(BBox other)
 {
     return(((Left <= other.Left && other.Left <= Right) || (other.Left <= Left && Left <= other.Right)) &&
            ((Bottom <= other.Bottom && other.Bottom <= Top) || (other.Bottom <= Bottom && Bottom <= other.Top)));
 }
示例#4
0
 public override void Translate(Vector2d delta)
 {
     this.bbox = bbox.Translated(delta);
 }
示例#5
0
 public BoxGeom(BBox bbox)
 {
     this.bbox = bbox;
 }
示例#6
0
 public BoxGeom(double x0, double y0, double x1, double y1)
 {
     bbox = new BBox(x0, y0, x1, y1);
 }
示例#7
0
 public override Intersection IntersectBBox(BBox other)
 {
     return(null);
 }
示例#8
0
 public abstract Intersection IntersectBBox(BBox other);