Orthographic Projection of a Plane, Rotated on Two Axes, and Viewed from an Oblique Angle Context: When installing a solar panel array in a landscape (assume flat terrain, and no obstructions with shade), sometimes the plot of land does not allow an orientation to due south (the optimal in the northern hemisphere). So, the array must be turned horizontally, away from south. (Also assume this is fixed, and cannot move in any way, once installed.) There are different opinions about a perfect tilt angle, even in the due south case. I'm not interested in actual research on cloud cover, time of day, nearby weather trends, etc. My question is about the math involved in tilting the panels up from zero degree tilt (facing straight up), after rotating the array x degrees horizontally, in order to maximize the area viewed by (exposed to) the sun. (What is the new optimal tilt, that would maximize the "projected" area, as if seen through a window by the sun, and we measure the area within an outline on the window?)
For example, once we have decided on the tilt angle for a perfect, south oriented array, such as 30 degrees, how does the trigonometry work for adjusting that tilt for every degree of orientation. Specifically, is there a simple formula that comes from the matrix(ices), where you can plug in the variables such as original optimal tilt and degrees of rotation. Keep in mind, the original projection toward the sky is above horizontal, so any move in the horizontal is changing things on two axes. I would guess the trigonometry has to go through calculus, to get a formula for maximizing, and may also involve vectors, Any experts out there, who can simplify this? (I am a long way from understanding vectors and projections, and hence a simple formula would be nice.)
 A: Set up a coordinate system with its $x$ axis pointing towards the south, $y$ axis towards the east, and $z$ axis pointing straight up into the sky.  Find the direction of the sun at noon, and let that direction be given by a vector $n_1=(n_x, n_y, n_z)$.
Next, for a solar panel rotated by an angle $\phi$ counter clockwise from the south direction and having a tilt angle of $\theta$ from the horizontally flat direction, the unit normal vector pointing out of the panel into the sky is along the vector $n_2$ given by
$n_2 = (\sin \theta \cos \phi, \sin \theta \sin \phi, \cos \theta ) $
Now we simply want the dot product $n_1 \cdot n_2$ to be maximum, i.e. we want to maximize the following trigonometric function $f(\theta, \phi)$
$f(\theta, \phi) = n_x \sin \theta \cos \phi + n_y \sin \theta \sin \phi + n_z \cos \theta $
For a given horizontal rotation $\phi = \phi_0$, this becomes
$f(\theta) = \sin \theta (n_x \cos \phi_0 + n_y \sin \phi_0 ) + n_z \cos \theta $
The maximum of this function occurs at $\theta = \theta_0$.  Where,
$\cos \theta_0 = \dfrac{ n_z }{ \sqrt{n_z^2 + (n_x \cos \phi_0 + n_y \sin \phi_0)^2 } } $
So $\theta_0$ is the tilt angle that maximizes utilization of the sun rays for a horizontal rotation $\phi_0$ of the solar panel.
A: For any future inquirers, here's the most simplified formula for this specific scenario: Set $n_z$ to $1$. Set $n_y$ to $0$, which drops the sine term. Then $n_x$ becomes $\tan\theta$.
$$\theta_0 = \operatorname{arccos} [ [1 + (\tan\theta \cos\phi_0)^2]^{-1/2} ]$$
