Hi All,

I am trying to transform pan & tilt degrees into tilt & bank degrees for a solar tracking application. (see photo)

My trig skills have waned over the years. Can anyone here help?

Attachment 18060

Thanks.

T

Printable View

- Jul 1st 2010, 06:44 AMTrackerPan tilt to tilt bank transform
Hi All,

I am trying to transform pan & tilt degrees into tilt & bank degrees for a solar tracking application. (see photo)

My trig skills have waned over the years. Can anyone here help?

Attachment 18060

Thanks.

T - Jul 10th 2010, 05:00 PMAckbeet
It looks like what you're doing is reversing the order of rotations. Is that correct? I think of rotations in terms of matrix multiplication. If you have a 3-dimensional vector,

$\displaystyle \vec{r}=\left[\begin{matrix}x\\ y\\ z\end{matrix}\right],$

you can rotate it about the x-axis through an angle $\displaystyle \theta$ by left-multiplying by a rotation matrix to obtain the rotated vector $\displaystyle \vec{r}_{\text{rot}}$ thus:

$\displaystyle \vec{r}_{\text{rot}}=

\left[\begin{matrix}

1 &0 &0\\

0 &\cos(\theta) &-\sin(\theta)\\

0 &\sin(\theta) &\cos(\theta)\end{matrix}\right]\left[\begin{matrix}x\\ y\\ z\end{matrix}\right].$

The other rotations you can see here.

Now, in your case, it looks like in the pan tilt case, you're applying a z rotation followed by an x or y rotation (depending on your orientation). In the tilt bank case, it's a little hard to see exactly what you're doing. The picture is a bit hard to decipher. Your pan tilt is like this, correct? Can you possibly draw a clearer picture of the tilt bank case? - Jul 10th 2010, 08:58 PMTrackerBetter picture
Thanks Ackbeet,

I was wondering if this one was going to get answered.

Attached is a better picture of what I am trying to transform. On the left is the normal pan and tilt similar to the pan tilt camera you linked. The top red tilt axis is rotated about the vertical pan axis (blue). The red axis rotates atop the blue axis in the direction indicated. On the right, the red tilt axis is rotated in the direction indicated and the yellow bank axis is attached to the red tilt axis so that it is rotated with it. The bank axis then rotates about it's own axis. This is actually already built and I am attempting to do the transform to track the sun given pan and tilt degrees.

I knew the transform involved doing a matrix but 20 years of not using it has left me in the lurch on this one.

The solar panel sits atop the bank axis and a combination of the tilt and bank axes will allow the tracker to follow the sun via the NREL software. Any help is appreciated. I'm trying to get this into a formula form so I can feed pan and tilt into it and dump out tilt and bank degrees.

Attachment 18165

Thanks again,

T - Jul 12th 2010, 05:09 AMAckbeet
Thanks for the second picture. It's definitely clearer than the first.

Let's assign some variables to things. In the pan/tilt picture, let the $\displaystyle \hat{i}$ axis be along the red rod, oriented positively from left to right. Let the $\displaystyle \hat{j}$ axis be along the blue rod, oriented positively up. By the right-hand rule, then, we must have the $\displaystyle \hat{k}$ axis be coming out of the picture towards us, and orthogonal to both the previous axes. Let us suppose you have a camera mounted on the red rod. I'm going to assume that, if the pan is at $\displaystyle 0$ radians, and the tilt is also at $\displaystyle 0$ radians, then the camera would then be pointed straight up, in the $\displaystyle +\hat{j}$ direction. Is all this clear?

In the tilt/bank picture, we will utilize the same coordinate system. That is, the $\displaystyle \hat{i}$ axis is along the red rod, oriented positively from left to right. The $\displaystyle \hat{j}$ axis is vertical (where the yellow rod would be if it were vertical), and positive up. And the $\displaystyle \hat{k}$ axis is coming out of the picture. In this picture, we would need to have the camera mounted on the yellow rod so that if the tilt were at $\displaystyle 0$ radians, and the bank were at $\displaystyle 0$ radians, the camera would be pointed in the positive $\displaystyle \hat{i}$ direction. Is that clear?

The problem then becomes: given an $\displaystyle \alpha$ pan rotation followed by a $\displaystyle \beta$ tilt rotation, all applied to the unit $\displaystyle \hat{j}$ vector, resulting in the arbitrary unit vector $\displaystyle \hat{r}$: produce the same vector by applying first a $\displaystyle \gamma$ tilt rotation, followed by a $\displaystyle \delta$ bank rotation, all applied to the unit $\displaystyle \hat{i}$ vector. Is this correct? - Jul 12th 2010, 07:17 AMTrackerPan tilt description
Hi Ackbeet,

Quote:

Let's assign some variables to things. In the pan/tilt picture, let the http://www.mathhelpforum.com/math-he...bfab68f5af.png axis be along the red rod, oriented positively from left to right. Let the http://www.mathhelpforum.com/math-he...5354331dbb.png axis be along the blue rod, oriented positively up. By the right-hand rule, then, we must have the http://www.mathhelpforum.com/math-he...a73184980c.png axis be coming out of the picture towards us, and orthogonal to both the previous axes. Let us suppose you have a camera mounted on the red rod. I'm going to assume that, if the pan is at http://www.mathhelpforum.com/math-he...f9f98764da.png radians, and the tilt is also at http://www.mathhelpforum.com/math-he...f9f98764da.png radians, then the camera would then be pointed straight up, in the http://www.mathhelpforum.com/math-he...da0d61d3fd.png direction. Is all this clear?

Quote:

In the tilt/bank picture, we will utilize the same coordinate system. That is, the http://www.mathhelpforum.com/math-he...bfab68f5af.png axis is along the red rod, oriented positively from left to right. The http://www.mathhelpforum.com/math-he...5354331dbb.png axis is vertical (where the yellow rod would be if it were vertical), and positive up. And the http://www.mathhelpforum.com/math-he...a73184980c.png axis is coming out of the picture. In this picture, we would need to have the camera mounted on the yellow rod so that if the tilt were at http://www.mathhelpforum.com/math-he...f9f98764da.png radians, and the bank were at http://www.mathhelpforum.com/math-he...f9f98764da.png radians, the camera would be pointed in the positive http://www.mathhelpforum.com/math-he...bfab68f5af.png direction. Is that clear?

Quote:

The problem then becomes: given an http://www.mathhelpforum.com/math-he...5149852f08.png pan rotation followed by a http://www.mathhelpforum.com/math-he...59ed813421.png tilt rotation, all applied to the unit http://www.mathhelpforum.com/math-he...5354331dbb.png vector, resulting in the arbitrary unit vector http://www.mathhelpforum.com/math-he...20124ae381.png: produce the same vector by applying first a http://www.mathhelpforum.com/math-he...ae65c1de79.png tilt rotation, followed by a http://www.mathhelpforum.com/math-he...e15357ad29.png bank rotation, all applied to the unit http://www.mathhelpforum.com/math-he...bfab68f5af.png vector. Is this correct?

It is amazing how much one can forget. It's like I'm learning it all over again.

Thank you for the assistance, I'd love to borrow your brain for a couple of days.

T. - Jul 12th 2010, 09:35 AMAckbeet
Ah. Your last post explains why I didn't launch into any computations yet. I was expecting there to be some mechanical limitations on your system. When we finally get an equation that does what you want, you're going to have to put in checks on the results to make sure they are in the feasible region.

I don't suppose you could draw the default position of your solar panel into the picture, could you? Or maybe, you could give a vector triple: $\displaystyle \langle x,y,z\rangle$ that describes the initial orientation of the panel? Here's my guess at what you meant: with the yellow rod pointed in the $\displaystyle -\hat{k}$ direction, a vector normal to the working plane of the solar panel would point in the $\displaystyle \frac{\langle 0,1,-1\rangle}{\sqrt{2}}$ direction. Is that correct? - Jul 12th 2010, 10:21 AMTrackerNew Picture
Hi again,

See the attached modified pic. I hope that clears it all up. I knew going in that the mechanical limitations would not allow a sun up to sun down track of the sun and have already coded the program to stop the tracking process when the limits are reached. The sun in my location at the summer solstice on the pan and tilt pans over 180 degress. I never would have thought that but it is true.

The panel mounted to the round side of the bank axis has it's normal in facing straight up in the picture.

Attachment 18177

Thanks again,

T - Jul 12th 2010, 11:59 AMAckbeet
Ok. I'm going to need to think about this one some more. My initial idea isn't working. I'll get back to you.

- Jul 12th 2010, 01:19 PMTrackerOK, I'll wait
See how you are the only one to try to help and I have no choice, I guess I'll wait.

Thanks,

T - Jul 13th 2010, 09:28 AMAckbeet
I've got the answer, and I'm pretty sure it's correct. I'll post the punch-line now, and give the justification later, when I have time to type it up (it's a bit long). This has been a very fun problem. Thanks for posting it!

In the pan/tilt case, if the pan angle is $\displaystyle \alpha$, and the tilt angle is $\displaystyle \beta$, and if in the tilt/bank case the tilt angle is $\displaystyle \gamma$ and the bank angle is $\displaystyle \delta$, then the following equations hold:

$\displaystyle \sin(\delta)=\sin(\alpha)\sin(\beta),$ and

$\displaystyle \cos(\gamma)=\frac{\cos(\beta)}{\sqrt{1-\sin^{2}(\alpha)\sin^{2}(\beta)}}.$

Try that on for size. As I said above, I'll post the justification when I have the time. - Jul 13th 2010, 09:47 AMTracker
Hey Ackbeet,

This was much more elegant than I had imagined it would be. I'm going to test it over the next couple of days and see how it does. I'll let you know. You are the man. Next time I have a completely baffling problem, I know who to call.

Thank you for all of your hard work.

T - Jul 13th 2010, 10:09 AMAckbeetJustification
Ok, here goes:

According to the wiki on matrix rotations in 3D, the following matrix rotates the positive $\displaystyle \hat{j}$ through an angle $\displaystyle \theta=\pi/2$ to the positive $\displaystyle \hat{k}$:

$\displaystyle R_{x}(\theta)=\left[\begin{matrix}1 & 0 & 0 \cr 0 & \cos (x) & -\sin (x) \cr 0 & \sin (x) & \cos (x) \cr\end{matrix}\right].$

You can check that this works. Also, the following matrix rotates the positive $\displaystyle \hat{k}$ through an angle $\displaystyle \theta=\pi/2$ to the positive $\displaystyle \hat{i}$:

$\displaystyle R_{y}(\theta)=\left[\begin{matrix}\cos (x) & 0 & \sin (x) \cr 0 & 1 & 0 \cr -\sin (x) & 0 & \cos (x) \cr\end{matrix}\right].$

Finally, the following matrix rotates the positive $\displaystyle \hat{i}$ through an angle $\displaystyle \theta=\pi/2$ to the positive $\displaystyle \hat{j}$:

$\displaystyle R_{z}(\theta)=\left[\begin{matrix}\cos (x) & -\sin (x) & 0 \cr \sin (x) & \cos (x) & 0 \cr 0 & 0 & 1 \cr\end{matrix}\right].$

In comparing these rotations to the rotations in your latest picture, it is evident that in the pan/tilt case, you have the following two rotations: $\displaystyle R_{x}(-\beta)$ and $\displaystyle R_{y}(\alpha).$ Similarly, in the tilt/bank case, you have the following rotations: $\displaystyle R_{z}(\delta)$ and $\displaystyle R_{x}(-\gamma).$

Query: is the pan/tilt case giving us $\displaystyle R_{x}(-\beta)R_{y}(\alpha)\hat{j},$ or $\displaystyle R_{y}(\alpha)R_{x}(-\beta)\hat{j}?$ It is not self-evident which one is correct. Note that these two*are not the same*, since matrix multiplication is not commutative. However, by plugging in a simple base case of $\displaystyle \alpha=\pi/2$ and $\displaystyle \beta=\pi/2$, you can check that the correct order is $\displaystyle R_{y}(\alpha)R_{x}(-\beta)\hat{j}.$ Similarly, for the tilt/bank case, the correct order is $\displaystyle R_{x}(-\gamma)R_{z}(\delta)\hat{j}.$ We now simply set

$\displaystyle R_{y}(\alpha)R_{x}(-\beta)\hat{j}=R_{x}(-\gamma)R_{z}(\delta)\hat{j}.$

This gives us the following system of simultaneous equations:

$\displaystyle \left[\begin{matrix}

-\sin(\alpha)\sin(\beta)\\ \cos(\beta)\\ -\cos(\alpha)\sin(\beta)

\end{matrix}\right]=\left[\begin{matrix}

-\sin(\delta)\\ \cos(\gamma)\cos(\delta)\\ -\cos(\delta)\sin(\gamma)

\end{matrix}\right].$

The solution I gave in post #10 satisfies all three of these equations.

So there's my solution, leaving out a few steps in the middle here and there.

You're very welcome for this solution. I enjoyed it!

Have a good one. - Jul 13th 2010, 11:14 AMAckbeet
One further note: for computational efficiency, you might consider coding up this transformation as follows:

$\displaystyle \sin(\delta)=\sin(\alpha)\sin(\beta),$ and

$\displaystyle \cos(\gamma)=\frac{\cos(\beta)}{\sqrt{1-\sin^{2}(\delta)}}=\frac{\cos(\beta)}{\cos(\delta) }.$

The idea here is, you use the first equation to compute $\displaystyle \delta$, and then you have what you need to compute $\displaystyle \gamma$ from the second equation. - Jul 13th 2010, 02:56 PMTracker
Ok, I ran some test data though excel with columns added for the above calculations.

I'm checking to make sure I didn't botch the transfer into Excel.

Here is the tilt calculation:

=DEGREES(ASIN(SIN(RADIANS(D2))*SIN(RADIANS(F2))))

Where D column contains the Pan Degrees and F column contains the tilt degrees.

Here is the bank calculation:

=DEGREES(ACOS(COS(RADIANS(F2))/COS(RADIANS(L2))))

Where F column contains the tilt degrees and L column contains the result of the tilt calculation.

In hindsight, I probably should have given you a data set to work with.

If I run a column of tilt data at a constant 21 degree tilt and a column of pan information from 0 to 180 I get a nice smooth translation with 90° being solar zenith. Next I'll go to MIDC: Solar Position Algorithm (SPA) Calculator for some real data to run through it.

Thanks again,

T - Jul 26th 2010, 04:45 PMTrackerConfirmation
Hey there,

It has been a while but the tracker is done and has been tested. It works beautifully. Thank you once again for a job well done!

Tracker