473,326 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Phases of the earth

Ivo
Hello all, while I am no astronomer or mathematician, I was wondering if
anyone could shed some light on the following question.
The phases of the moon have intrigued mankind since the dawn of time.
Astronomers have spent the ages developing magical, eh, mathematical
algorithms to predict (and postdict) the waning and waxing years and
millenia ahead.
Now plotting the current shape of the crescent in JavaScript, based on the
internal clock, takes about twenty lines. See:
<URL: http://www.eskimo.com/~jet/javascrip...moonphase.html >

But there is another repetitive shadow, that we are increasingly seeing on
computer generated world maps: that of the night. It 's the same kind of
shadow, but cycling in just 24 hours, and projected on a flattened surface.
So the question, does anyone know of a script that plots the current area's
of dusk, night and dawn on a worldmap? Many servserside language seem
capable of it, so it shouldn't be too difficult to implement in JavaScript
with a given jpg or gif where the equator, dateline and Greenwich pixel
positions are known.
To get the idea, see the shaded sinus at for example these sites:
<URL: http://www.fourmilab.ch/cgi-bin/uncg.../action?opt=-p >
<URL: http://www.die.net/earth/ >

Reinventing the wheel is silly, so translating an existing program to
Javascript seems the most sensible approach, but I haven't been able to find
the code for one just yet.
Many thanks,
ivo
http://4umi.com/image/wallpaper/worldmap.jpg

Jul 6 '06 #1
4 2294
Ivo wrote:
Hello all, while I am no astronomer or mathematician, I was wondering if
anyone could shed some light on the following question.
The phases of the moon have intrigued mankind since the dawn of time.
Astronomers have spent the ages developing magical, eh, mathematical
algorithms to predict (and postdict) the waning and waxing years and
millenia ahead.
Now plotting the current shape of the crescent in JavaScript, based on the
internal clock, takes about twenty lines. See:
<URL: http://www.eskimo.com/~jet/javascrip...moonphase.html >

But there is another repetitive shadow, that we are increasingly seeing on
computer generated world maps: that of the night. It 's the same kind of
shadow, but cycling in just 24 hours, and projected on a flattened surface.
So the question, does anyone know of a script that plots the current area's
of dusk, night and dawn on a worldmap? Many servserside language seem
capable of it, so it shouldn't be too difficult to implement in JavaScript
with a given jpg or gif where the equator, dateline and Greenwich pixel
positions are known.
To get the idea, see the shaded sinus at for example these sites:
<URL: http://www.fourmilab.ch/cgi-bin/uncg.../action?opt=-p >
<URL: http://www.die.net/earth/ >

Reinventing the wheel is silly, so translating an existing program to
Javascript seems the most sensible approach, but I haven't been able to find
the code for one just yet.
Many thanks,
ivo
http://4umi.com/image/wallpaper/worldmap.jpg
To do that sinus thing, I would probably just overlay a PNG with a
semi-transparent black sinusoid onto the world map and position it
correctly. It would take some ugly tricks to make the PNG work in IE
but I think it would be the simplest way.

Disregarding IE (which I know you probably can't do, but this might give
you an idea):

HTML:
<div id="worldMap">
<div id="shadow"></div>
</div>

CSS:
#worldMap
{
width: (width of worldmap image)px;
height: (height of worldmap image)px;
background-image: url((path to worldmap image));
}

#worldMap #shadow
{
width: 100%;
height: 100%;
background-image: url((path to shadow image));
}

javascript:
function setMapTime(time)
{
/*...
do some stuff to figure out horizontal
position of maximum
*/

document.getElementById("shadow").style.background Position = hPos + "px
0px";
//where hPos is the horizontal maximum's position in px
}

All you would really have to do is change the background-position of the
shadow (assuming that image is tileable, which it should be). Of
course, that won't work in IE since it won't support repeating PNG
backgrounds until version 7 comes out. You could approximate the same
thing using a GIF, but you wouldn't get the semi-transparency effect.

Jeremy
Jul 7 '06 #2
Ivo
"Jeremy" schreef
Ivo wrote:
>So the question, does anyone know of a script that plots the current
area's of dusk, night and dawn on a worldmap? Many servserside language
seem capable of it, so it shouldn't be too difficult to implement in
JavaScript with a given jpg or gif where the equator, dateline and
Greenwich pixel positions are known.
To get the idea, see the shaded sinus at for example these sites:
<URL: http://www.fourmilab.ch/cgi-bin/uncg.../action?opt=-p >
<URL: http://www.die.net/earth/ >

To do that sinus thing, I would probably just overlay a PNG with a
semi-transparent black sinusoid onto the world map and position it
correctly. It would take some ugly tricks to make the PNG work in IE but
I think it would be the simplest way.
<snip>
javascript:
function setMapTime(time)
{
/*...
do some stuff to figure out horizontal
position of maximum
*/

document.getElementById("shadow").style.background Position = hPos + "px
0px";
//where hPos is the horizontal maximum's position in px
}
<snip>
You could approximate the same thing using a GIF, but you wouldn't get
the semi-transparency effect.
Thanks Jeremy, these techniques certainly come into play, but I think at the
moment these are details compared to the bit in your comment block. What is
the arithmetic? The sinus moves horizontally around the map every 24 hours,
but it moves vertically every 365 days, changing shape all the time. Do we
need that many images? I hadn't really thought about the transparancy
problem, a plain dark area would be good enough for me, as long as every two
or three pixels (hunderds of miles on the map) is accounted for. You can
fake transparancy and oval shapes by plotting pixels, but there must a
formula.
Regards,
Ivo
Jul 7 '06 #3
Ivo wrote:
Thanks Jeremy, these techniques certainly come into play, but I think at the
moment these are details compared to the bit in your comment block. What is
the arithmetic? The sinus moves horizontally around the map every 24 hours,
but it moves vertically every 365 days, changing shape all the time. Do we
need that many images? I hadn't really thought about the transparancy
problem, a plain dark area would be good enough for me, as long as every two
or three pixels (hunderds of miles on the map) is accounted for. You can
fake transparancy and oval shapes by plotting pixels, but there must a
formula.
Regards,
Ivo

It changes shape? It moves vertically?

I was looking at this site
http://www.time.gov/timezone.cgi?Pacific/d/-8/java - which seems to do
what you're trying to do, only in the form of a Java applet. The image
they use seems pretty static to me, but maybe I'm wrong. Or, maybe you
need a more precise graph.

In any case, if it's just the math you're after, you might want to
additionally ask in a math or physics group.

The math you need actually depends on what method was used to project
your world map. You'll need to come up with a function that maps the
time of day to a three dimensional unit vector that points from the
center of the earth to the sun. Then you'll need to use the same
projection function as your world map (it's probably either a
cylindrical projection or a spherical projection) to project the
intersection of the plane defined by that vector with the orb of the
earth into a curve. That is, if you want to be really precise about it.

See, if you're not taking seasons into account, you can come up with a
good approximation using a static projection that moves horizontally.
Just use a world map that's projected onto the sun's viewing plane,
rather than a polar axis-aligned viewing plane. I think this is what
time.gov does, only they chop off equal amounts from the bottom and top
so that you don't notice that the north pole is larger than the south
pole in their projection (because you can see neither of them). Your
map may look a little "askew", but will not be any less of an accurate
representation.

Jeremy
Jul 7 '06 #4
JRS: In article <44***********************@news.wanadoo.nl>, dated Fri,
7 Jul 2006 00:14:51 remote, seen in news:comp.lang.javascript, Ivo
<no@thank.youposted :
>The phases of the moon have intrigued mankind since the dawn of time.
>But there is another repetitive shadow, that we are increasingly seeing on
computer generated world maps: that of the night. It 's the same kind of
shadow, but cycling in just 24 hours, and projected on a flattened surface.
Not entirely. The Moon has no atmosphere, so it should be sufficient to
indicate where the centre of the Sun (or its upper edge) is above the
horizon.

For the Earth, however, there are at least four boundaries to indicate;
when the Sun's centre or top is on the horizon, and when the Sun's
centre is 6 / 12 / 18 degrees below the horizon - Civil / Nautical /
Astronomical Twilight boundaries. In each case one should allow for
atmospheric refraction.

<URL:http://www.merlyn.demon.co.uk/misctime.htmand references,
including Whitaker's Almanac.

Since at least 99% of the Dutch seem to speak perfect English, Whitaker
may well be available in the Netherlands; and, remembering Dutch
maritime history, there should be a Dutch equivalent too!

Or, no doubt, a Nautical Almanac, etc.

In such a map, it would be interesting also to show the sub-solar point;
and, by stepping in 24-h intervals, one can see the analemma.

I have no code; try Googling "Paul Schlyter", which may help.
Indeed, read the sci.astro FAQ, section C.03, via?
<URL:http://sciastro.astronomy.net/>.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demon.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/- see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 7 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

37
by: Xah Lee | last post by:
A Moronicity of Guido van Rossum Xah Lee, 200509 On Guido van Rossum's website: http://www.artima.com/weblogs/viewpost.jsp?thread=98196 dated 20050826, he muses with the idea that he would...
1
by: xahlee | last post by:
Elisp Tutorial: Make Google Earth Xah Lee, 2006-12 This page shows a example of writing a emacs lisp function that creates a Google Earth file, and creates a link to the file, as well a link...
1
by: Ken Fine | last post by:
Hi, hoping someone can help out with what's a simple question. I am using the ASP.NET VE map control here on a site, which I am still developing. I'm putting picture icons on a map: ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.