public double DistanceToPoint(Vector2 point) { var v1 = new Vector2(); var clampedPoint = v1.Copy(point).Clamp(this.min, this.max); return(clampedPoint.Sub(point).Length()); }
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); }