PhysicalTimeToGMT
The handler which I present here, turns your longitudinal position, int the hour angle of your local meredian offset from GMT.
The routine is supposed to be used for finding, the physical position of the earth, at a given time, so that you in turn can find the right ascension of some stellar object, or at least some similiar operation like: If the sun is at zenith at noon in GMT, when can I suspect the sun to be at zenith in my time. The reason I have made, it, is partly to find the right ascension of an object, partly, to figure out how many times the earth as rotated, since Vernal Equinox. The offset the hour angle of your local meredian being the center-piece, in such calculations.
It canāt be done without coordinates, (but the coordinates may not be as far away as you think they are, Iāll address this in a post below this.) Obviously, you canāt rely on the timezone given by your locale, nor time to GMT for this, since some of us have daylight savings, and some countrieās timezones are politicially chosen, because of trade, or other purposes. So, your timezone, and physical location, with regards to GMT may diverge.
I will now present a handler, that given a longitudinal coordinate as a decimal number, will return the offset of your local meredian to the Prime Meridan, the Greenwhich Meridian.
Since there are at least another, almost totally unrelated quantity named Hour angle, which is the hour angle of the sun, I call the hour angle we obtain here for āoffsetOfhourAngleOfLocalToGMTMeredian by decimalAngleā.
We donāt care about if we are fed geodetic, or geocentric coordinates here at this time, since I honestly havenāt thought through that problem, but the two types of coordinates, shouldnāt differ by much, and you should be safe if you use map coordinates (geodetic), which you are most likely to get your hands on, (from a book, or the net.
The handler is really supposed to get coordinates in the form [-180ā¦-1 or [0ā¦179] but it will convert it if it is in the regular 360Ć⢠form, and shovel off any multiples of 360!
The handler, could of course have been written more compactly, but I donāt see any point in turning parts of it into a (flip/flop) function. It doesnāt enhance readability, and an if test, must be faster than a modulus operation.
The hour angles of a local meridan (hereafter hour angles) are divided into 24 from 0 up to and including 23, said differently from and including 0, up to but not including 24. This principle just used that we are including the first term, but not the second, permeats the whole founcation from the calulation here.
Example:
Every meredian of a local timezone has a width of 15 degrees, the Greenwhich Meredian starts at -7.5Ć⢠and continues up to, but doesnāt include 7.5 degrees, where the Meredian of the timezone with an offset of 1 hour angle to the Greenwhich Meredian starts. If we had included 7.5Ć⢠in the Greenwhich Meredian, then it would have consisted of 16 degrees, and 16 times 24 = 384, clearly not what we are after.
The rest of the handler should be fairly evident, I all just state a last relation, a position, to the east of Greenwhich is Greenwhich + something, since the earth rotates westwards (hence sun gets up in the east, it reaches Greenwhich, before the position east of it. And a last fact, at noon, when you face the sun, the sun is directly south of your position.
to offsetOfhourAngleOfLocalToGMTMeredian by decimalAngle
# we remove any superfluos degrees first.
set decimalAngle to decimalAngle mod 360
# we make angles Ć¢ā°Ā„ 180 into negatives
if decimalAngle Ć¢ā°Ā„ 180 then
set decimalAngle to decimalAngle - 360
end if
local hourAngle
if decimalAngle < 0 then
set decimalAngle to (decimalAngle * -1) - 0.1
# we have to skew the numbers by -0.1 to keep
# boundary conditions
set hourAngle to (24 - ((decimalAngle + 7.5) div 15)) mod 24
else
set hourAngle to (decimalAngle + 7.5) div 15
end if
return hourAngle
end offsetOfhourAngleOfLocalToGMTMeredian
set res to offsetOfhourAngleOfLocalToGMTMeredian by -8.6
# or whatever
Edit
I should have mentioned, that youāll find a handler for converting from deg,h,m,s to a decimal angle here, and the handler as well.
Addendum
Sometimes it may be convenient to have an hour angle given in ±12 hours.
Therefore the handler below.
# Converts an hour angle given in the interval 0 - 23
# to intervals -1..-12 and 0..11 offset to before or after
# the Greenwhich Meredian.
# set semiH to semiCircHourAngle from 1
to semiCircHourAngle from CircularHourAngle
if CircularHourAngle > 11 then
return ((12 - (CircularHourAngle mod 12)) * -1)
else
return CircularHourAngle
end if
end semiCircHourAngle