示例#1
0
        public double DistanceToPoint(Vector2 point)
        {
            var v1 = new Vector2();

            var clampedPoint = v1.Copy(point).Clamp(this.min, this.max);

            return(clampedPoint.Sub(point).Length());
        }
示例#2
0
        public Box2 SetFromCenterAndSize(Vector2 center, Vector2 size)
        {
            var v1 = new Vector2();

            var halfSize = v1.Copy(size).MultiplyScalar(0.5);

            this.min.Copy(center).Sub(halfSize);
            this.max.Copy(center).Add(halfSize);

            return(this);
        }