Construct a procedure which determines the location of the shadow of a rectangluar box. I drew a 3d rectangular box on a coordinate plan consisting of x, y, and z. A procedure is to be created that will determine the location of the shadow of the box on one of the coordinate planes. I have trouble thinking in more than 2 dimensions so any help would be greatly appreciated!
 A: Assuming that you have a point source light, Find the equation of the line that passes through the light source and one of the vertexes of the box. Then project this line to the appropriate plane. Repeat for all vertexes, and you have the shadow outline. This is known in computer graphics as stencil shadows. If you want some example math, I can do that.
I assume that you know the points of your box (or other shape), and which points are connected by lines. I will use the unit cube $[0,0,0] \rightarrow [1,1,1]$ for simplicity. The light source will be at $(2,2,2)$.
For corner $(0,0,0)$:
Ray goes: $(2,2,2) \rightarrow (0,0,0)$:
$$\vec r_{ray}=\vec p_{cube}-\vec p_{light} = <0,0,0>-<2,2,2>=<-2,-2,-2>$$
This gives us the direction of the ray. When using a direction vector to characterize a line (this is the 3D slope), we often normalize. Therefore:
$$\vec r_{normray}=\frac{\vec r_{ray}}{|\vec r_{ray}|}=<\frac{-1}{\sqrt{3}},\frac{-1}{\sqrt{3}},\frac{-1}{\sqrt{3}}>$$
The equation of a line in 3D is just like the point-slope formula, where the above direction vector is the slope. We already know that the light source must lie on the line, so that's the point we need. We now have all the information to construct the line that describes the light ray. I did not use the normalized form to simplify the algebra.
$$\vec r_{lightray}(t)=\vec p_{light}+t\cdot \vec r_{ray}$$
Plug in numbers.
$$\vec r_{lightray}(t)=(2,2,2)+t \cdot <-2,-2,-2>$$
For the XY plane, we have $z=0$. Solve $0=2-2t$ (z-coordinate). From that, we get the $t$ to plug into $x$ and $y$, and from that we have the point of the shadow.
$$z:0=2-2t \rightarrow t=1$$
$$x:x_{lightray}=2-2(t=1) \rightarrow x_{lightray}=0$$
$$x:y_{lightray}=2-2(t=1) \rightarrow y_{lightray}=0$$
So the shadow corner is at point $(0,0,0)$.
For the XY plane, and box corner $(0,1,1)$. Therefore:
$$\vec r_{ray}=\vec p_{cube}-\vec p_{light} = <0,1,1>-<2,2,2>=<-2,-1,-1>$$
$$\vec r_{lightray}(t)=\vec p_{light}+t\cdot \vec r_{ray}$$
$$\vec r_{lightray}(t)=(2,2,2)+t \cdot <-2,-1,-1>$$
$$z:0=2-1t \rightarrow t=2$$
$$x:x_{lightray}=2-2(t=2) \rightarrow x_{lightray}=-2$$
$$x:y_{lightray}=2-1(t=2) \rightarrow y_{lightray}=0$$
Therefore, the shadow point is: $(-2,0,0)$.
