Method for Calculating the longitude and latitude of a direct sun point

Source: Internet
Author: User

In a three-dimensional system, you must determine the sun position based on time and set this position as a specific light source.

To produce real lighting and shadow effects

 

The method for calculating the longitude and latitude of the direct sun point is as follows:

Based on the basic geographic knowledge,

Latitude: the latitude of a place with a height of 90 degrees

Longitude: the longitude of the place at noon.

 

The longitude is relatively good, 24 hours a day, the earth 360 degrees,

Longitude, time difference of 4 minutes

The longitude changes every minute, while the latitude changes every day.

 

Let's take a look at the longitude calculation method.

Export double callback calclongitude (double currlong, double currtime) <br/>{< br/> double res = 0.0; <br/> If (currlong> = 0) <br/> {<br/> res = (12.0-currtime) * 15.0 + currlong; <br/> If (RES> 180.0) <br/>{< br/> res-= 360.0; <br/>}< br/> else <br/> {<br/> res = currlong-(currtime-12.0) * 15.0; <br/> If (RES <-180.0) <br/> res + = 360.0; <br/>}< br/> return res; <br/>} 

 

Latitude calculation method, adapted from Python code on the Internet

The specific parameters are not understood, but the actual test is consistent with the actual situation.

Int calcday (INT year, int month, int day) <br/>{< br/> int leap = 0; <br/> If (Year % 4 = 0 & year % 100! = 0) | year % 400 = 0) <br/>{< br/> leap = 1; <br/>}< br/> else <br/> {<br/> leap = 0; <br/>}< br/> int mm [12] = {120, leap + 59, leap + 90, leap + 151, leap + 181, leap +, leap + 212, leap + 243, leap + 273, leap + 304, leap + 334}; <br/> return mm [month-1] + Day; <br/>}< br/> export double callback calclatitude (INT year, int month, int day) <br/>{< br/> Double tick = calcday (year, month, day)-79.6764-0.2422 * (year-1985) + int (year-1985)/4 ); <br/> double Sita = 2*3.14159265 * tick/365.2422; <br/> Double Delta = 0.3723 + 23.2567 * sin (SITA) <br/> + 0.1149 * sin (2 * SITA)-0.1712 * sin (3 * SITA) <br/>-0.758 * Cos (SITA) + 0.3656 * Cos (2 * SITA) <br/> + 0.0201 * Cos (3 * SITA); <br/> return delta; <br/>} 

 

Reference: http://blog.chinaunix.net/u/21370/showart_390554.html

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.