Nez.Portable/Physics/Shapes/RealtimeCollisions.cs
/// <summary>
/// checks to see if circle overlaps box and returns (via out param) the point of intersection
/// </summary>
/// <returns><c>true</c>, if circle box was tested, <c>false</c> otherwise.</returns>
/// <param name="circle">Circle.</param>
/// <param name="box">Box.</param>
/// <param name="point">Point.</param>
checks to see if circle overlaps box and returns (via out param) the point of intersection
checks to see if circle overlaps box and returns ( via out param ) the point of intersection
public static bool testCircleBox(Circle circle, Box box, out Vector2 point)
        {
            point = box.bounds.getClosestPointOnRectangleFToPoint(circle.position);
            var v = point - circle.position;
            float dist;
            Vector2.Dot(ref v, ref v, out dist);
            return dist <= circle.radius * circle.radius;
        }
public static bool testCircleBox ( Circle circle , Box box , out Vector2 point ) { point = box . bounds . getClosestPointOnRectangleFToPoint ( circle . position ) ; var v = point - circle . position ; float dist ; Vector2 . Dot ( ref v , ref v , out dist ) ; return dist <= circle . radius * circle . radius ; }
checks to see if circle overlaps box and returns (via out param) the point of intersection
checks to see if circle overlaps box and returns ( via out param ) the point of intersection
// find the point closest to the sphere center // circle and box intersect if sqr distance from circle center to point is less than the circle sqr radius
None
circle
Circle
None
box
Box
None
Vector2
out
point
None