Log in

No account? Create an account
public service math lesson: spherical trigonometry 
28th-Nov-2012 11:01 am
So I've arbitrarily decided that more people need to know about spherical trigonometry. (e.g., just in case the GPS gets destroyed and we're stuck having to do our own navigation again.)

It's really the same solving of triangles that you learned to do in high school geometry/trig, i.e., gimme side-angle-side or angle-side-angle to nail down what the triangle actually is, then use Law of Sines or Law of Cosines or some combination thereof to work out the previously unknown sides/angles that you care about.

It's just that some of the rules for spherical trig are a Little Bit Different.

So, jumping right into the deep end, here's an application inspired by recent events:
You, an observer stationed on planet Earth at some particular latitude, want to know where the sun is going to be in the sky at some particular time of day, some particular day of the year.
And, cutting to the chase, here's a triangle to solve:

If you know b, A, c (side, angle, side), you can solve for a (opposite side) using the Law of Cosines
cos a = cos b cos c + sin b sin c cos A
and then B (next angle) using the Law of Sines
sinB/sinb = sinA/sina = sinC/sinc
In case you're wondering, what we're looking at here is the celestial globe, i.e., the really-far-away sphere that has all of the stars glued to it — yes we're using ancient Greek cosmology; cope — viewed from the outside, looking directly down on the observer, hence the zenith being in the middle and the observer's horizon being the circle around the outside. Other things to know:
  • The globe spins around the observer once a day, rotating about the celestial poles.
  • The stars are fixed on this globe but the sun and planets move around.
  • The plane of the solar system shows up here as the great circle of the ecliptic, which the sun goes around once a year, crossing the celestial equator in two places, the vernal and autumnal equinoxes.
  • "Declination" is another name for latitude on the celestial sphere; longitude is called "right ascension" (and no I don't know why they can't just say "latitude" and "longitude", nor if there's any such thing as "left ascension"; I guess there must be but ... buh...).
Here endeth the crash course in astronomy.

To summarize, if you know the observer's latitude, the declination of the sun, and the local time, then you can solve for the sun's bearing and altitude.

It is perhaps a little weird to be measuring the sides of the triangle using degrees, but that's how you measure distances on a sphere, where your "lines" are actually great circles and the size (radius) of the the sphere doesn't matter at all for anything we're going to talk about.

Purists may complain that I'm using degrees instead of radians, but really you can use whatever units are appropriate, and for some of these you might want to use time units instead (e.g., right ascension is typically expressed in units of hours or fractions of a day, and measurements along the ecliptic may well be best expressed in terms of [idealized] months or fractions of a solar year, for reasons that will become obvious if I'm explaining this right).

All very nice but where do you get the declination of the sun? That involves getting out your calendar and solving another triangle:

but this one's easier because it's a right triangle, and as you might recall that there are simple relationships between its various sides and angles; know any two out of the five numbers and you can derive the rest. [5 choose 3] = 10 possible relationships, and here they are:

spherical trig formulaanalogues from...
ordinary trighyperbolic trig
(warning, evil, don't look)
sin A = sin a / sin csin A = a/csin A = sinh a / sinh c  opposite over hypotenuse
cos A = tan b / tan ccos A = b/ccos A = tanh b / tanh c  adjacent over hypotenuse
tan A = tan a / sin btan A = a/btan A = tanh a / sinh b  opposite over adjacent
sin B = sin b / sin csin B = b/csin B = sinh b / sinh c  ... and again from the other corner
cos B = tan a / tan ccos B = a/ccos B = tanh a / tanh c
tan B = tan b / sin atan B = b/atan B = tanh b / sinh a
cos c = cos a cos bc² = a² + b²cosh c = cosh a cosh b  oooo, it's the Pythagorean Theorem!
cos b = cos B / sin A A + B = 90°cosh b = cos B / sin A  WTF?
cos a = cos A / sin Bcosh a = cos A / sin B
tan A tan B cos c = 1tan A tan B cosh c = 1

(and this is also enough to derive the various Laws of Sines and Cosines from but I won't do that...)

Line 1 gives us most of what we want:
declination of the sun
= arcsin(sin23° × sin(how far sun has moved since the vernal equinox))
And now we start to see some more of the differences between SphereLand and regular plane geometry. The biggie is that the parallel postulate — give me a line and a point not on it, there's a unique parallel line through the point that doesn't intersect the first line — has been replaced with an Evil Alien Pod Substitute Doppelganger: In SphereLand, every pair of distinct "lines" (great circles again) intersects, no exceptions; there is no such thing as "parallel".

In related news, the angles of a triangle now add up to 180° plus the area. E.g., it's fairly easy to build a triangle with 3 right angles — think North Pole−Ecuador−Congo here — (angle sum = 270°) whose area (270 − 180 = 90) is 1/8 of the entire sphere (which is either 720 spherical degrees or 4π steradians, depending on which units you prefer). Which also means there's no such thing as "similar triangles", i.e., no way to make a triangle bigger or smaller while keeping all of the angles the same. Which now means that angle-angle-angle can be added to the toolbox for nailing down triangles and there's this Extra Bonus Law of Cosines to use in such cases
cosA = sinB sinC cos a - cosB cosC
Meanwhile, back at the original problem, there are a couple of remaining issues.

The first issue is buried under one of the other parameters, innocuously labeled "time of day" in the figure above, which in this case means local solar time, i.e., the time of day that a sundial would give you. Which, to be fair, was, for most of recorded history, the definition of time that most normal people used. But in the context of this problem, it's begging the question a bit: we want to know where the sun is, to do that we need to know what time it is, and we tell time by seeing where the sun is. Oops.

To get out of this box we switch to the time definitions that we've actually been using for the past couple centuries, ones that play well with mechanical clocks and make life somewhat less miserable for railroads and interstate commerce. Specifically,
  1. we use a mean solar day, averaging out the days so that they're all the same length, so that our mechanical clock doesn't have to care what time of year it is. Best way to think of this is to place an imaginary "average sun" on the celestial equator, moving at a constant angular rate such that it takes the same amount of time to go from vernal equinox to vernal equinox that the real sun does. Every time this imaginary average sun reaches its highest point in your sky, that defines noon in your local mean solar time, which defines what a solar day is, and so on. Then
  2. to keep the railroads happy, we have time zones. Meaning that unless you live right on the meridian that defines your time zone, the clock on your wall/computer is actually showing Somebody Else's mean solar time and you have to add or subtract however many degrees away you are from that meridian to get your own.
Which leaves the matter of getting from local mean solar time to local actual sundial time, which then entails knowing
right ascension of the actual sun
= arctan(cos23° × tan(how far sun has moved since the vernal equinox))
as per line 2 of the table above. Once you know this, you know how much the right ascension of the actual sun is leading or lagging the right ascension of your imaginary mean sun, and hence what you need to add or subtract from your local mean solar time to get the actual sundial "time of day" angle.

The second issue has to do with a similar innocuous labeling "time of year" in the 2nd triangle, which bears the implicit assumption that sun's angular velocity along the ecliptic is itself a uniform 360° per solar year. It isn't, quite.

To be sure, the effect is fairly small but was still large enough to drive the ancient Greeks nuts. They added epicycles to their model to approximate what they were actually seeing, and, to be fair, they did such a good job of it that Claudius Ptolemy's compendium of their work in 150 CE (itself representing some 400-500 years of effort dating back to the founding of Plato's academy) lasted for at least another thousand years* as the definitive word on the subject, getting enshrined into Catholic doctrine to the point that Copernicus and Gallileo would risk getting burnt at the stake for having the audacity to submit bug reports.
*This might also be a measure just how thoroughly the onset of Christianity destroyed the advancement of science in the western world. Just saying...
And in this particular case it's not about whether you put the sun in the center. Because sun-earth is just a two-body problem, things work out either way — score one for Relativity — and working geocentrically often makes far more sense for earth-based problems. (To be sure, if you want to know what happens with Mars, then life gets Interesting).

The actual issue here is that (1) the sun's orbit about the earth is an ellipse, not a circle and (2) what's constant is not the angular rate of motion but rather the rate at which the moving sun sweeps out area per unit time. It took Johannes Kepler (1605) to figure this much out and it took until Isaac Newton to get a reasonable explanation for it (1687), i.e, that it was a consequence of angular momentum conservation, Kepler's own explanation being woo-woo theological/numerological bullshit. Although, to be fair, Newton has to handwave a bit, too, on the question of what momentum actually is; the idea that momentum conservation laws derive from symmetries comes quite a bit later, and there are inevitably yet more turtles lurking underneath.

For now, Kepler suffices. The only additional pieces of information we need are
  1. the eccentricity ε of the ellipse, or, alternatively, the factor by which you have to squunch the circle to get the ellipse (= √1−ε²), and
  2. the time of the most recent perihelion, closest approach of the sun, which, being a parameter of the Earth's orbital motion, has nothing to do with Vernal Equinox (which has to do with where the Earth's rotation axis is pointed). These days, perihelion happens in early January.
I say "these days" because, just to make life miserable,
  • Our civic calendar doesn't quite match the length of the solar year, though thanks, Pope Gregory, for trying, and this, at least, isn't that hard to work around.
  • The ecliptic moves around and drags the Vernal Equinox with it because solar/lunar tides acting on a not-entirely spherical Earth cause its rotation to precess; essentially each celestial pole traces out a circle every 25,000 years, so the solar year isn't quite what you think it is; and then there are lots of much smaller wobbles due to force-free precession, magma sloshing around, and other stupidity.
  • If there weren't any other planets in the solar system (cough-Jupiter-cough) and Albert Einstein had never been born, then perihelion would stay fixed, but it too shifts around a bit
but since these effects are all insanely small, and this post is long enough as it is, I'm going to ignore them.

Here's the magic diagram for doing the Kepler adjustment (the actual orbit of the sun is nowhere near this eccentric, by the way):

Given a time t you can solve for ζ (there probably isn't a closed form expression for this unless you want to learn about elliptic functions, which you probably don't [I haven't]; just use Newton's method...). Once you have ζ, you can easily get θ (yay, half-angle formulas and arctangents). You'll then need to do this all twice, the first time to nail down where the Vernal Equinox with is respect to perihelion, the second time to get the current position of the sun with respect to perihelion, and then you can subtract. Wheee.

You now have enough information to outdo Ptolemy, just in case you were wondering or just in case you get tossed back in time to ancient Rome and want to impress the rubes. Good luck with that.

I really should put the rules for general triangles here somewhere. You have 3 sides (a,b,c), and the 3 corresponding opposite angles (A,B,C), 6 numbers in all; know any 3 out of the 6 and you can derive the rest. There are [6 choose 4] = 15 relations in all, though since, unlike the right-triangle case, there isn't a distinguished side/angle, there are really only 4 distinct cases, the rest being obtainable by permuting the variables:

situationspherical triganalogues from ...
ordinary trighyperbolic trig
(warning, evil, don't look)
Law of SinesAASSsinA/sina = sinB/sinbsinA/a = sinB/bsinA/sinha = sinB/sinhb
Law of CosinesASSScosb cosc + sinb sinc cosA = cosaa² = b² + c² − 2bc cosAcoshb coshc − sinhb sinhc cosA = cosha
Bonus Law of CosinesAAASsinB sinC cosa − cosB cosC = cosAA + B + C = 180°sinB sinC cosha − cosB cosC = cosA
The Other 6 CasesASASsinc/tanb − sinA/tanB = cosc cosAsinhc/tanhb − sinA/tanB = coshc cosA
28th-Nov-2012 07:19 pm (UTC)
So I can't say as to how I actually paid attention in the equations, but I was at least amused by the prose...
28th-Nov-2012 07:29 pm (UTC)
What yduJ said ..
1st-Dec-2012 01:34 am (UTC)
Coincidentally, a whole bunch of shit broke at work yesterday and today, and the inciting incident was that someone misspelled "latitude" as "lattitude".
2nd-Dec-2012 01:50 pm (UTC)
You realize, of course, that it makes absolutely no sense that "latitude" has only two t's. English sucks.

Also amazing how, in an earlier era, the first printing would already be out into the world and there'd be nothing to be done about it, but now...
This page was loaded Aug 24th 2017, 10:31 am GMT.