This will probably be really simple but I've been working on it for a solid hour and I can't seem to solve it.

Uploaded with ImageShack.us

Basically I have a circle inside of a square and I wish to calculate the distance between the origin and the edge of the square. Sounds pretty simple ay?

I know the radius and thus all the dimensions of the square and the angle.

This is what i have:

r=radius

a = angle

b = 90 - a

c = r * cos(a);

d = r * sin(b);

and then whichever is smaller c or d is the distance. This doesn't work, at least it doesn't seem to

Many thanks in advance

Conor