Confusing with an articles wording on Clamping a Vector2

I have been reading an article on Collision Detection and how to resolve it.

http://www.wildbunny.co.uk/blog/2011/04/20/collision-detection-for-dummies/

In the section describing an AABB vs Circle, it states:

The first step is to get the centre of the circle and project it on to the boundary of the AABB. Fortunately this is as easy as forming the vector V between AABB and circle and simply clamping it against the half extents of the AABB.

In the picture provided, it makes sense. You get the vector between the two objects, and then get the closest virtice to the circle and use that in your computation.

But, how DO you take the width/height into account to that new vector? He says "..simply clamping it against the half extends of the AABB"

Can anyone clarify what he means?

A clamp (or saturate) is constraining a value to be within a range of values, that is:

v' = max(low, min(high, v))

In this case, he wants you to clamp each component of the vector to the corresponding min/max on that axis.

x = max(-halfWidth,  min(halfWidth, circleX-boxX))
y = max(-halfHeight, min(halfHeight, circleY-boxY))


This will yield a point on the boundary of the box if the circle center is outside the box, or a point inside the box if the circle is inside.

By doing this, you can treat the box as a circle centered at the box center, with the circumference going through that point.