Radius of a hypercube at a given angle For a ray from the origin with a given angle in $R^n$, I am trying to find the radius at which that ray intersects the frontier of the unit n-cube. In two dimensions, the picture is this:

Given $\theta$, find the distance r to the edge of the unit square. Or, in $n$ dimensions, given angles $\theta_1,...,\theta_{n-1}$, find the distance $r$ to the edge of the unit hypercube.
If somebody could provide a good source of information on doing trigonometry in arbitrary dimensions, that may be enough. As it is I don't know how to approach this problem.
 A: In 2D it is min$(1/\cos\theta, 1/\sin\theta)$  Where are you measuring your angles?  In 3D, is $\theta_1$ the angle in the plane as you show and $\theta_2$ the angle out of the plane? 
A: In higher dimensions it is usually best to use a directional vector from the sphere $S^{n-1}$  instead of an angle $\theta$.  For convex bodies (or even star bodies) the radial function. $\rho$: $S^{n-1}$$\rightarrow R_{\ge0}$ gives the radius of the body in a particular direction.  In your case, you are working with the $l_\infty$ ball.  The radial function, when restricted to $S^{n-1}$ is simply the receprical of the minkowski functional:
http://en.wikipedia.org/wiki/Minkowski_functional
In short, you need a "nice" formula for the radial function $\rho$ of the $l_\infty$ ball.  You may find such a formula in a convex geometry book.  In particular, Koldobsky has a book on Fourier analysis and convex geometry which contains extensive results on $l_p$ balls and radial functions.  
I'll edit my answer if I think of more specific references.  
