+ /* calculate the angle between v->surface_to_sun and
+ * v->surface_east. We do this so we can sort out the acos()
+ * ambiguity. I wish I could think of a more efficient way ... :-( */
+ east_dot = MAT3_DOT_PRODUCT(v->surface_to_sun, v->surface_east);
+ printf(" East dot product = %.2f\n", east_dot);
+
+ /* calculate the angle between v->surface_to_sun and
+ * v->surface_south. this is how much we have to rotate the sky
+ * for it to align with the sun */
+ dot = MAT3_DOT_PRODUCT(v->surface_to_sun, v->surface_south);
+ printf(" Dot product = %.2f\n", dot);
+ if ( east_dot >= 0 ) {
+ angle = acos(dot);
+ } else {
+ angle = -acos(dot);
+ }
+ printf(" Sky needs to rotate = %.3f rads = %.1f degrees.\n",
+ angle, angle * RAD_TO_DEG);
+