# Sunny thoughts

Now I just need to convince the installer to prop up one edge of each panel by 13.5" (22 degrees over a 36" radius), or something.

For those who want the gory details:

In 3 dimensions, we start with a vector that represents the direction the panel is pointing when it's laying flat on the ground. I've picked y as my "up" axis - it really doesn't matter as long as you don't forget which is which. p={0,1,0}
Now I use 2 rotational matrices: R for the roof and T for the side-tilt that I'm adding. (I'll use bold to indicate a matrix). The result of applying the 2 rotations is the q vector.
q = R * T * p
In constructing R, I chose to rotate around the z axis:
The roof tilt angle is "r"
 cos(r) -sin(r) 0 R= sin(r) cos(r) 0 0 0 1

I used x as the T pivot axis:
I "t" is the side-tilt angle.
 1 0 0 T= 0 cos(t) -sin(t) 0 sin(t) cos(t)

Now, to tighten this up into a single matrix, I'll multiply R and T to get a new matrix: B.
The new equation will look like this:
B = R * T
and
q = B * p
and B is:
 cos(r) -sin(r)*cos(t) sin(r)*sin(t) B= sin(r) cos(r)*cos(t) -cos(r)*sin(t) 0 sin(t) cos(t)

multiply by the flat panel vector (p)
and I get the equations for x, y, and z or the result vector (q)
x=-sin(r)*cos(t)
y=cos(r)*cos(t)
z=sin(t)
But I want the angles in azimuth and elevation, so let me use the inverse tangent. atan2() takes x and y separately, instead of just the quotient.
azimuth = atan2(z,x)
elevation = atan2(y, sqrt(x^2+z^2))

or

azimuth = atan2( sin(t), -sin(r)*cos(t))
elevation = atan2(cos(r)*cos(t),sqrt(sin^2(r)*cos^2(t)+sin^2(t)))
Now, I discover that "r" has a special meaning in Grapher (of course)
so I used "a" instead of "r". I want the angles to plot as y values, so I'll write two equations for y (that's how you get 2 lines in Grapher).

And, I really want to graph this stuff as a function of the side-tilt,
so I replaced "t" with "x". Don't confuse this x with the original x axis.
azimuth:
y = atan2(sin(x), -sin(a)*cos(x))

elevation:
y = atan2(cos(a)*cos(x),sqrt(sin^2(a)*cos^2(x)+sin^2(x)))

Later,
Bob
home