Rolling a box on a spherical surface (with a Float Script controller)

Hi everybody!
First of all sorry for my bad english.
I'm trying to automate the way a box would "roll" on a spherical surface.
Since those objects would be part of a character rig, I need a script controller to be able to automate that kind of movement.

The problem for the first part for the movement is described in 2D with a circle and a rectangle in the image I attach to this post.

Any help would be very appreciated!
Thanks in advanced!

rolling-plain-to-spherical_problem.jpg142.25 KB