<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>eDesign.nl &#187; Image processing</title>
	<atom:link href="http://www.edesign.nl/category/image-processing/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.edesign.nl</link>
	<description>Thoughts and concepts on software development</description>
	<lastBuildDate>Fri, 08 Apr 2011 13:35:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>HTML5 Canvas experiments</title>
		<link>http://www.edesign.nl/2011/03/23/html5-canvas-experiments/</link>
		<comments>http://www.edesign.nl/2011/03/23/html5-canvas-experiments/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 21:45:11 +0000</pubDate>
		<dc:creator>Jurgen</dc:creator>
				<category><![CDATA[Image processing]]></category>

		<guid isPermaLink="false">http://www.edesign.nl/?p=841</guid>
		<description><![CDATA[

HTML5 is supported by more and more browsers. It has a nice feature called the &#8216;canvas&#8217; element. It is an element on which you can &#8216;paint&#8217; using e.g. JavaScript. I experimented with this new canvas element. You can view the experiments (clock, 3D-axis and rotation, ray tracer) and view the source too! The ray tracer [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste">
<p><a href="http://www.edesign.nl/wp-content/uploads/2011/03/03-01_html5_canvas_element_ld_img.png"><img class="size-medium wp-image-843 alignleft" title="HTML5 Canvas element" src="http://www.edesign.nl/wp-content/uploads/2011/03/03-01_html5_canvas_element_ld_img-300x109.png" alt="HTML5 Canvas element" width="150" height="54" /></a></p>
<p>HTML5 is supported by more and more browsers. It has a nice feature called the &#8216;canvas&#8217; element. It is an element on which you can &#8216;paint&#8217; using e.g. JavaScript. I experimented with this new canvas element. You can view <a href="http://www.edesign.nl/examples/html5/" target="_blank">the experiments</a> (<a href="http://www.edesign.nl/examples/html5/clock/index.php?mode=ns" target="_blank">clock</a>, <a href="http://www.edesign.nl/examples/html5/rotate/" target="_blank">3D-axis and rotation</a>, <a href="http://www.edesign.nl/examples/html5/raytrace/" target="_blank">ray tracer</a>) and view the source too! The ray tracer should be activated in Chrome or Safari as Firefox and Internet Explorer tend to be (very) slow.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.edesign.nl/2011/03/23/html5-canvas-experiments/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Math behind a world sunlight map</title>
		<link>http://www.edesign.nl/2009/05/14/math-behind-a-world-sunlight-map/</link>
		<comments>http://www.edesign.nl/2009/05/14/math-behind-a-world-sunlight-map/#comments</comments>
		<pubDate>Thu, 14 May 2009 00:59:29 +0000</pubDate>
		<dc:creator>Jurgen</dc:creator>
				<category><![CDATA[Algorithms]]></category>
		<category><![CDATA[Image processing]]></category>

		<guid isPermaLink="false">http://www.edesign.nl/?p=434</guid>
		<description><![CDATA[My neighbour has a map of the world on the wall. You can see it from the street in front of his house. It has a backlight but that only illuminates half of the map. The transition from day to night is shaped like a sine wave most of the time. It actually is a [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-436" href="http://www.edesign.nl/2009/05/14/math-behind-a-world-sunlight-map/full-17572/"><img class="alignleft size-thumbnail wp-image-436" title="World sunlight map fraction" src="http://www.edesign.nl/wp-content/uploads/2009/05/full-17572-150x150.jpg" alt="World sunlight map fraction" width="150" height="150" /></a>My neighbour has a map of the world on the wall. You can see it from the street in front of his house. It has a backlight but that only illuminates half of the map. The transition from day to night is shaped like a sine wave most of the time. It actually is a <a href="http://www.geochronusa.com/new_geo/" target="_blank">physical world sunlight map</a>. Of course, you can <a href="http://www.die.net/earth/" target="_blank">simulate this </a>with a computer too. There even is an <a href="http://www.daylightmap.com/index.php" target="_blank">instance using Google maps</a>.</p>
<p>As many roads lead to Rome multiple ways are possible to this simulation. One could model the sun, earth, maybe more and start <a href="http://en.wikipedia.org/wiki/Ray_tracing_(graphics)" target="_blank">ray tracing</a>. This approach would include solar eclipses but is quite heavy by means of the load on the processor. Because of the number of calculations involved in ray tracing is quite high. The way I choose to describe fully in this article is one close to it. Using <a href="http://en.wikipedia.org/wiki/Euclidean_vector" target="_blank">vectors</a> pointing from a sphere (<a href="http://en.wikipedia.org/wiki/Earth" target="_blank">earth</a>) to a point (<a href="http://en.wikipedia.org/wiki/Sun" target="_blank">sun</a>) I map a <a href="http://en.wikipedia.org/wiki/Mercator_projection" target="_blank">Mercator projected map</a> of the world on the sphere. The challenges included are the yearly orbit of earth around the sun and it&#8217;s 23.5° tilted 24 hour spin.<span id="more-434"></span></p>
<p>About a decade ago I made a similar program in highschool. I didn&#8217;t know vectors and <a href="http://en.wikipedia.org/wiki/Trigonometry" target="_blank">trigonometry</a> then as I do now. Back then I used to have the map of the world where for each longitude (the ones parallel to the equator) I calculated sunset and sunrise times for that longitude. This way I knew when to start painting night over the daylight map I had. This result was pretty accurate and an <a href="http://users.electromagnetic.net/bu/astro/sunrise-set.php" target="_blank">algorithm to determine those solar times</a> is not hard to implement. This time I used another more advanced approach to the problem.</p>
<h2>Space</h2>
<p>First let us define a mathematical 3D space, with three axis: <img src="http://www.edesign.nl/wp-content/cache/tex_9dd4e461268c8034f5c8564e155c67a6.png" align="absmiddle" class="tex" alt="x" /> (pointing from left to right), <img src="http://www.edesign.nl/wp-content/cache/tex_415290769594460e2e485922904f345d.png" align="absmiddle" class="tex" alt="y" /> (pointing up) and <img src="http://www.edesign.nl/wp-content/cache/tex_fbade9e36a3f36d3d676c1b808451dd7.png" align="absmiddle" class="tex" alt="z" /> (pointing into your monitor). Pointing directions are given to help your imagination. Axis point from small (negative infinite) to big (positive infinite), they intersect at <img src="http://www.edesign.nl/wp-content/cache/tex_80c93660da9d0792e674ba1085c32ace.png" align="absmiddle" class="tex" alt="O_{x,y,z} = (0, 0, 0)" />.</p>
<h2>Earth</h2>
<p>Define a sphere on point <img src="http://www.edesign.nl/wp-content/cache/tex_f186217753c37b9b9f958d906208506e.png" align="absmiddle" class="tex" alt="O" />, with a radius of 1. This will be the earth. The funny thing is that for every point<img src="http://www.edesign.nl/wp-content/cache/tex_5808829302c573af69fc6aa7f83b41e6.png" align="absmiddle" class="tex" alt="\vec{p}" />(x,y,z coordinate) on the earth, because the earth is centered around <img src="http://www.edesign.nl/wp-content/cache/tex_f186217753c37b9b9f958d906208506e.png" align="absmiddle" class="tex" alt="O" />, automatically is the same a the vector pointing orthoganally away from the earth starting on that point<img src="http://www.edesign.nl/wp-content/cache/tex_5808829302c573af69fc6aa7f83b41e6.png" align="absmiddle" class="tex" alt="\vec{p}" />. This comes in handy when we do calculations later on.</p>
<p><center><img src="http://www.edesign.nl/wp-content/plugins/easy-latex/cache/tex_33380c0b9e4cdcdf3e81f1180aea86ba.png" title="\vec{p} = (x, y, z)" class="etex" alt="\vec{p} = (x, y, z)" /></center></p>
<h2>Sun</h2>
<p>We don&#8217;t need the sun for this method. We only need the direction to it from the earth. So define a vector <em>S</em> which points in the direction of the sun from <img src="http://www.edesign.nl/wp-content/cache/tex_f186217753c37b9b9f958d906208506e.png" align="absmiddle" class="tex" alt="O" />. To do this we must use sine and cosine. On time <img src="http://www.edesign.nl/wp-content/cache/tex_1f48e973d6a9075dbaaf41a9e85f034e.png" align="absmiddle" class="tex" alt="t = 0" /> the direction of the sun will be <img src="http://www.edesign.nl/wp-content/cache/tex_4967dfa815448036b242326491623bad.png" align="absmiddle" class="tex" alt="(1, 0, 0)" />, which is a vector pointing to the right. On <img src="http://www.edesign.nl/wp-content/cache/tex_7fcd6686b2518bb9eefd38d7531edfba.png" align="absmiddle" class="tex" alt="t = 12" /> (hour) that should be pointing right <img src="http://www.edesign.nl/wp-content/cache/tex_d12de2b341d428af7c1eeab87422c070.png" align="absmiddle" class="tex" alt="(-1, 0, 0)" />. The same goes for 6 o&#8217;clock am and pm, being respectively <img src="http://www.edesign.nl/wp-content/cache/tex_8da033c96917f68a2d4465bf831bf683.png" align="absmiddle" class="tex" alt="(0, 1, 0)" /> and <img src="http://www.edesign.nl/wp-content/cache/tex_069359415cada53c746dae706831bb51.png" align="absmiddle" class="tex" alt="(0, -1, 0)" />. This gives us insight that the direction <img src="http://www.edesign.nl/wp-content/cache/tex_954322810f486ac24f0d70218627d2a0.png" align="absmiddle" class="tex" alt="\vec{d}" /> to the sun can be given as (<img src="http://www.edesign.nl/wp-content/cache/tex_e358efa489f58062f10dd7316b65649e.png" align="absmiddle" class="tex" alt="t" /> should be scaled to a value from 0 to 1, so we need to divide <img src="http://www.edesign.nl/wp-content/cache/tex_e358efa489f58062f10dd7316b65649e.png" align="absmiddle" class="tex" alt="t" /> by 24):</p>
<p><center><img src="http://www.edesign.nl/wp-content/plugins/easy-latex/cache/tex_3150abfca1663b9bdd3db560ded4268b.png" title="\vec{d} =(\cos{\frac{2\pi t}{24}}, 0, \sin{\frac{2\pi t}{24}})" class="etex" alt="\vec{d} =(\cos{\frac{2\pi t}{24}}, 0, \sin{\frac{2\pi t}{24}})" /></center></p>
<p>With this approach we actually make the sun rotate around the earth.</p>
<h2>Tilted earth</h2>
<div id="attachment_459" class="wp-caption alignleft" style="width: 310px"><a rel="attachment wp-att-459" href="http://www.edesign.nl/2009/05/14/math-behind-a-world-sunlight-map/north_season/"><img class="size-medium wp-image-459" title="Earth tilted axis" src="http://www.edesign.nl/wp-content/uploads/2009/05/north_season-300x165.jpg" alt="Earth tilted axis" width="300" height="165" /></a><p class="wp-caption-text">Tilted orbit of the spinning earth around the sun. The method discussed here turns it around as it models the sun orbitting the earth.</p></div>
<p>The above formula still is not complete. The axis around which the earth is spinning is not orthogonal to the plane defined by the orbit of the earth around the sun. It is tilted 23.5°. This is how we get the four seasons on earth of course. To model this a nice trick can be applied to <em>d</em>. We know that on or closely around June 21th the sun is right above the 23.5° latitude (<a href="http://en.wikipedia.org/wiki/Tropic_of_Cancer" target="_blank">Tropic of Cancer</a>), the <a href="http://en.wikipedia.org/wiki/Solstice">summer solstice</a>. From here it takes a sine with a period of a year to go to -23.5° and back again. June 21th is the 172th day of the year. The standard cosine function has the form:</p>
<p><center><img src="http://www.edesign.nl/wp-content/plugins/easy-latex/cache/tex_4059e79313887878e46828ae448a06bc.png" title="y = a \cdot \cos{(bx + c)} + d" class="etex" alt="y = a \cdot \cos{(bx + c)} + d" /></center></p>
<p>We can simply fill this out. The <img src="http://www.edesign.nl/wp-content/cache/tex_0cc175b9c0f1b6a831c399e269772661.png" align="absmiddle" class="tex" alt="a" /> must be 23.5, <img src="http://www.edesign.nl/wp-content/cache/tex_92eb5ffee6ae2fec3ad71c777531578f.png" align="absmiddle" class="tex" alt="b" /> is <img src="http://www.edesign.nl/wp-content/cache/tex_744d20bf0129464fb19fee5dd435a613.png" align="absmiddle" class="tex" alt="\frac{2\pi}{365}" />, <img src="http://www.edesign.nl/wp-content/cache/tex_4a8a08f09d37b73795649038408b5f33.png" align="absmiddle" class="tex" alt="c" /> is -172 and <img src="http://www.edesign.nl/wp-content/cache/tex_8277e0910d750195b448797616e091ad.png" align="absmiddle" class="tex" alt="d" /> equals 0. If you define <img src="http://www.edesign.nl/wp-content/cache/tex_415290769594460e2e485922904f345d.png" align="absmiddle" class="tex" alt="y" /> the observable tilt (because the real tilt will always be 23.5) and <img src="http://www.edesign.nl/wp-content/cache/tex_9dd4e461268c8034f5c8564e155c67a6.png" align="absmiddle" class="tex" alt="x" /> is the day of the year:</p>
<p><center><img src="http://www.edesign.nl/wp-content/plugins/easy-latex/cache/tex_9fd4ce29cabb03153f7a603bfe765419.png" title="observableTilt = 23.5 \cos{(\frac{2\pi}{365} ({dayOfYear} - 172))}" class="etex" alt="observableTilt = 23.5 \cos{(\frac{2\pi}{365} ({dayOfYear} - 172))}" /></center></p>
<p>Now this observable tilt is the angle there is between what is the real direction to the sun and the already calculated direction <em>d</em>. To calculate the vector (<img src="http://www.edesign.nl/wp-content/cache/tex_415290769594460e2e485922904f345d.png" align="absmiddle" class="tex" alt="y" /> component, pointing up or down) which should be added to <img src="http://www.edesign.nl/wp-content/cache/tex_954322810f486ac24f0d70218627d2a0.png" align="absmiddle" class="tex" alt="\vec{d}" /> to get the real direction you can use tangens.</p>
<p><center><img src="http://www.edesign.nl/wp-content/plugins/easy-latex/cache/tex_bfe8c80f2cfd4c7d565b2c8084c718d0.png" title="\vec{tiltCorrection} = \vec{d} \cdot \tan{ 2\pi \frac{observableTilt}{360}}" class="etex" alt="\vec{tiltCorrection} = \vec{d} \cdot \tan{ 2\pi \frac{observableTilt}{360}}" /></center></p>
<p>Then the real direction vector <img src="http://www.edesign.nl/wp-content/cache/tex_0b41e62b40d2668f0de148e45d42f78e.png" align="absmiddle" class="tex" alt="\vec{rd}" /> is the addition of <img src="http://www.edesign.nl/wp-content/cache/tex_7c54a32d6ac073f230f089ae1703bfc5.png" align="absmiddle" class="tex" alt="\vec{tiltCorrection}" /><em> </em>to <img src="http://www.edesign.nl/wp-content/cache/tex_954322810f486ac24f0d70218627d2a0.png" align="absmiddle" class="tex" alt="\vec{d}" />:</p>
<p><center><img src="http://www.edesign.nl/wp-content/plugins/easy-latex/cache/tex_ac1ecf22584f2bbba1b86a580ce3b2c7.png" title="\vec{rd} = \vec{tiltCorrection} + \vec{d}" class="etex" alt="\vec{rd} = \vec{tiltCorrection} + \vec{d}" /></center></p>
<h2>Calcultating illumination and mapping</h2>
<p>Using the <a href="http://mathworld.wolfram.com/DotProduct.html" target="_blank">dot product</a> (or <a href="http://www.netcomuk.co.uk/~jenolive/vect6.html" target="_blank">scalar product</a> or <a href="http://en.wikipedia.org/wiki/Dot_product" target="_blank">inner product</a>) you can calculate the angle between two vectors. Or, if the vectors are both normalized (length = 1) it is the projection of the one vector onto the other. So if we calculate the dot product for every normal vector from the surface of the earth (<img src="http://www.edesign.nl/wp-content/cache/tex_5808829302c573af69fc6aa7f83b41e6.png" align="absmiddle" class="tex" alt="\vec{p}" />) with <img src="http://www.edesign.nl/wp-content/cache/tex_0b41e62b40d2668f0de148e45d42f78e.png" align="absmiddle" class="tex" alt="\vec{rd}" /> we should get some meaningful results.</p>
<p><center><img src="http://www.edesign.nl/wp-content/plugins/easy-latex/cache/tex_934bbf22f5024754ad96d504e678bdab.png" title="illumination = \vec{rd} \cdot \vec{p}" class="etex" alt="illumination = \vec{rd} \cdot \vec{p}" /></center></p>
<p>If the <img src="http://www.edesign.nl/wp-content/cache/tex_f47cdb7d31a3b19cebc72d46123a33b7.png" align="absmiddle" class="tex" alt="illumination &lt; 0" /> the sun is in another direction so <img src="http://www.edesign.nl/wp-content/cache/tex_5808829302c573af69fc6aa7f83b41e6.png" align="absmiddle" class="tex" alt="\vec{p}" /> is pointing to the night side of the earth. If <img src="http://www.edesign.nl/wp-content/cache/tex_f68036c925fc7246cbd239e8cd6c41e0.png" align="absmiddle" class="tex" alt="illumination \geq 0" /> that piece of earth recieves solar light.</p>
<p>We have a 2D map (Mercator projection) we need to map on the 3D sphere. We need to do this to determine which we need to calculate dot products for. To avoid confusion, lets call <em>x</em> and <img src="http://www.edesign.nl/wp-content/cache/tex_415290769594460e2e485922904f345d.png" align="absmiddle" class="tex" alt="y" /> from the 2D map <img src="http://www.edesign.nl/wp-content/cache/tex_7b774effe4a349c6dd82ad4f4f21d34c.png" align="absmiddle" class="tex" alt="u" /> and <img src="http://www.edesign.nl/wp-content/cache/tex_9e3669d19b675bd57058fd4664205d2a.png" align="absmiddle" class="tex" alt="v" />. We can iterate for each <img src="http://www.edesign.nl/wp-content/cache/tex_7b774effe4a349c6dd82ad4f4f21d34c.png" align="absmiddle" class="tex" alt="u" /> and each <img src="http://www.edesign.nl/wp-content/cache/tex_9e3669d19b675bd57058fd4664205d2a.png" align="absmiddle" class="tex" alt="v" /> for each <img src="http://www.edesign.nl/wp-content/cache/tex_7b774effe4a349c6dd82ad4f4f21d34c.png" align="absmiddle" class="tex" alt="u" /> and map it to a <img src="http://www.edesign.nl/wp-content/cache/tex_5808829302c573af69fc6aa7f83b41e6.png" align="absmiddle" class="tex" alt="\vec{p}" /> in 3D. To do this we need to determine phi (<img src="http://www.edesign.nl/wp-content/cache/tex_1ed346930917426bc46d41e22cc525ec.png" align="absmiddle" class="tex" alt="\phi" />, logitude: <img src="http://www.edesign.nl/wp-content/cache/tex_9e3669d19b675bd57058fd4664205d2a.png" align="absmiddle" class="tex" alt="v" />)and theta (<img src="http://www.edesign.nl/wp-content/cache/tex_2554a2bb846cffd697389e5dc8912759.png" align="absmiddle" class="tex" alt="\theta" />, latitude: <img src="http://www.edesign.nl/wp-content/cache/tex_7b774effe4a349c6dd82ad4f4f21d34c.png" align="absmiddle" class="tex" alt="u" />). In the iteration (<img src="http://www.edesign.nl/wp-content/cache/tex_e862d31aae219d30f927d5835bb1aefa.png" align="absmiddle" class="tex" alt="maxV" /> is the height of the map and <img src="http://www.edesign.nl/wp-content/cache/tex_ce778d1af59137ea75e31062e9b5071a.png" align="absmiddle" class="tex" alt="maxU" /> is the width of the map):</p>
<p><center><img src="http://www.edesign.nl/wp-content/plugins/easy-latex/cache/tex_ea04300b34f21520a92879871d570de7.png" title="\phi = 2\pi (\frac{v}{maxV})" class="etex" alt="\phi = 2\pi (\frac{v}{maxV})" /></center><br />
<center><img src="http://www.edesign.nl/wp-content/plugins/easy-latex/cache/tex_8a9c80d2a42b86a8030ef85d5fc9134e.png" title="\theta = 2\pi (\frac{u}{maxU})" class="etex" alt="\theta = 2\pi (\frac{u}{maxU})" /></center></p>
<p>Now <img src="http://www.edesign.nl/wp-content/cache/tex_7b774effe4a349c6dd82ad4f4f21d34c.png" align="absmiddle" class="tex" alt="u" /> and <img src="http://www.edesign.nl/wp-content/cache/tex_9e3669d19b675bd57058fd4664205d2a.png" align="absmiddle" class="tex" alt="v" /> map to <img src="http://www.edesign.nl/wp-content/cache/tex_5808829302c573af69fc6aa7f83b41e6.png" align="absmiddle" class="tex" alt="\vec{p}" /> <a href="http://en.wikipedia.org/wiki/Sphere#Equations_in_R3" target="_blank">as follows</a>:</p>
<p><center><img src="http://www.edesign.nl/wp-content/plugins/easy-latex/cache/tex_da487b437d943ae2192deb8d49f55840.png" title="\left\{\begin{matrix} \vec{p}_x = \sin{\phi} \cos{\theta} \\ \vec{p}_y = \cos{\theta} \\ \vec{p}_z = \sin{\phi} sin{\theta} \end{matrix}\right." class="etex" alt="\left\{\begin{matrix} \vec{p}_x = \sin{\phi} \cos{\theta} \\ \vec{p}_y = \cos{\theta} \\ \vec{p}_z = \sin{\phi} sin{\theta} \end{matrix}\right." /></center></p>
<p>Now we can for each coordinate <img src="http://www.edesign.nl/wp-content/cache/tex_f406f917636fcaa71ae578800a9700f5.png" align="absmiddle" class="tex" alt="(u, v)" /> on the map if it should be displayed as day or night.</p>
<h2>Fun with shading</h2>
<p>Because you know the angle the sunlight makes with the earth&#8217;s surface you can make add some shading by making it increasingly dark on the edges of the day. It the dot product of <img src="http://www.edesign.nl/wp-content/cache/tex_5808829302c573af69fc6aa7f83b41e6.png" align="absmiddle" class="tex" alt="\vec{p}" /> and <img src="http://www.edesign.nl/wp-content/cache/tex_0b41e62b40d2668f0de148e45d42f78e.png" align="absmiddle" class="tex" alt="\vec{rd}" /> is smaller than 0.1 (<img src="http://www.edesign.nl/wp-content/cache/tex_a45c2c2471bdd7da560847792785984c.png" align="absmiddle" class="tex" alt="illumination &lt; 0.1" />) the point is in dusk or dawn and you could mix day and night as a gradient to make the difference between them look more fluently. Another joke is the reflection of the sun: if the product is greater than, let&#8217;s say, 0.95 (<img src="http://www.edesign.nl/wp-content/cache/tex_0d4df00bd8936b0588687977c7e6cde1.png" align="absmiddle" class="tex" alt="illumination &gt; 0.95" />) the sun is approximately orthogonally above that coordinate an you could make it more white to have it look like the sun is reflecting in the map.</p>
<h2>Demo and discussion</h2>
<p>A <a href="http://www.edesign.nl/examples/sunlightmap/" target="_blank">demontration of this method</a> is available at the edesign example site. There are a number of assumptions done and restrictions set while creating this demo.</p>
<div class="wp-caption aligncenter" style="width: 510px"><a href="http://www.edesign.nl/examples/sunlightmap/"><img title="Live World Sunlight map" src="/examples/sunlightmap/map.php" alt="" width="500" height="250" /></a><p class="wp-caption-text">Live sunlight map generated using the algorithm discussed in this article. Click the image to go to the example page where you can override current time.</p></div>
<ul>
<li>I assumed the solar rays are parallel. The distance from the sun to the earth is huge, but it is actually wrong to assume rays are parallel. They are only by approximation so it is good enough for this simulation.</li>
<li>Because of this assumption, the night &#8217;starts&#8217; exactly at the half of the world in the shade while actually this is different. The sun is far bigger than the earth and therefor some rays should be able to reach the shadow half of the earth (near the limit depicted in the first image). By approximation I eliminated this too.</li>
<li>Timing is not very accurate. As well as for the 24h clock as for the solstices rough estimates are used.</li>
<li>A perfect sphere is taken as world. No fattening is modelled (polar radius should be smaller than equatorial radius).</li>
<li>The &#8216;fun with shading&#8217; should implement something to make land mass not reflect sunlight.</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.edesign.nl/2009/05/14/math-behind-a-world-sunlight-map/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
	</channel>
</rss>

