473,671 Members | 2,514 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2324
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.getEle mentById("shado w").style.backg roundPosition = 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.getEle mentById("shado w").style.backg roundPosition = 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************ ***********@new s.wanadoo.nl>, dated Fri,
7 Jul 2006 00:14:51 remote, seen in news:comp.lang. javascript, Ivo
<no@thank.youpo sted :
>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.demo n.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.astron omy.net/>.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/- w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.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
3541
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 like to remove lambda, reduce(), filter() and map() constructs in a future version Python 3000.
1
7287
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 to Google Map. If you don't know elisp, first take a gander at Elisp Basics. I often write travelogs on my website. If i traveled to Las Vegas, then
1
1143
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: http://kenfine.posterous.com/uw-map-overhead I am using the ASP.NET VE server control in 3d mode, as you see. I can specify an overhead view that is accurate using the following declaration.
0
8483
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8401
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8926
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8824
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8603
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8673
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7444
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4416
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.