3
$\begingroup$

Say we have a space of dimension $D$. Say we have a $D$-cube of side $l$ centered at the origin and inside it we have a point $P\in \mathbb{R}^D$ and a collection of $D-1$ angles $\phi_1, \phi_2, \ldots \phi_{D-1}$. Then, say we have a line $r$ that is defined by the point $P$ and the angles.

Is there any nice formula to determine the points where the line and the cube will intersect?

$\endgroup$

1 Answer 1

6
$\begingroup$

Convert your angles $\phi_1, \ldots \phi_{d-1}$ to a unit vector $v$. Then solve $p_i + t v_i = \pm 1$ for each $i=1,\ldots,d$. This yields the scale factor $t$ that reaches the $i$-th hyperplane above $+$ or below $-$. The minimum positive $t$ of all these $2d$ solutions is the first cube face hit by $p + t v = u$.


            CubeVector
Then scale by $l/2$.

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .