6
$\begingroup$

How do I get the longitude/latitude from zenith/azimuth?

Or how can I position my sun in a 3d application?

code extracted from here

public static AzimuthZenithAngle getSolarAzimuthZenithFromLatLon(float lat, float lon) {
   GregorianCalendar time = new GregorianCalendar(TimeZone.getDefault());
   return PSA.calculateSolarPosition(time, lat, lon);
}

public static Vector3 getSolarPosition(float radius, AzimuthZenithAngle az) {
    double a = az.getAzimuth();
    double z = az.getZenithAngle();

    float X  = (float) (radius*Math.sin(z)*Math.cos(a));
    float Y  = (float) (radius*Math.sin(z)*Math.sin(a));
    float Z  = (float) (radius*Math.cos(z));

    return new Vector3(X, Y, Z);
}

this is my code, but it's not working very well.

$\endgroup$
3
  • $\begingroup$ Is the observer at (0,0,0), or else radius large in comparison to the observer coordinates? Or could you specify, in which way the code behaves different from your expectation? The transformation from spherical coordinates to euclidean looks ok to me at first glance. $\endgroup$
    – Gerald
    Feb 26, 2014 at 22:47
  • $\begingroup$ Do you mean altitude-azimuth? The zenith is a "fixed" point, not the current angle above the horizon of the sun $\endgroup$
    – Jeremy
    Mar 13, 2014 at 20:14
  • $\begingroup$ I think you are asking two different questions. Determining the lat and long from zenith altitude and azimuth is one thing, plotting the position of the sun is another (and requires additional input parameters) $\endgroup$
    – Jeremy
    Mar 13, 2014 at 20:28

2 Answers 2

5
$\begingroup$

Well let's see:

Local Standard Time Meridian (LSTM)

The Local Standard Time Meridian (LSTM) is a reference meridian used for a particular time zone and is similar to the Prime Meridian, which is used for Greenwich Mean Time. The (LSTM) is calculated according to the equation: $$ LSTM = 15^{o}.\Delta T_{GMT} $$ where $\Delta T_{GMT}$ is the difference of the Local Time (LT) from Greenwich Mean Time (GMT) in hours.

Equation of Time (EoT)

The equation of time (EoT) (in minutes) is an empirical equation that corrects for the eccentricity of the Earth's orbit and the Earth's axial tilt. $$ EoT = 9.87 sin\left(2B\right) - 7.53cos\left(B\right) - 1.5 sin\left(B\right) $$

Where $B = \frac{360}{365}\left(d - 81\right) $ in degrees and d is the number of days since the start of the year.

Time Correction Factor (TC)

The net Time Correction Factor (in minutes) accounts for the variation of the Local Solar Time (LST) within a given time zone due to the longitude variations within the time zone and also incorporates the EoT above. $$ TC = 4\left(Longitude - LSTM\right) + EoT $$ The factor of 4 minutes comes from the fact that the Earth rotates 1° every 4 minutes.

Local Solar Time (LST)

The Local Solar Time (LST) can be found by using the previous two corrections to adjust the local time (LT). $$ LST = LT + \frac{TC}{60} $$

Hour Angle (HRA)

The Hour Angle converts the local solar time (LST) into the number of degrees which the sun moves across the sky. By definition, the Hour Angle is 0° at solar noon. Since the Earth rotates 15° per hour, each hour away from solar noon corresponds to an angular motion of the sun in the sky of 15°. In the morning the hour angle is negative, in the afternoon the hour angle is positive. $$ HRA = 15^{o}\left(LST - 12\right) $$

Declination angle:

The declination angle denoted by $\delta$, varies seasonally due to the tilt of the Earth on its axis of rotation and the rotation of the Earth around the sun. If the Earth were not tilted on its axis of rotation, the declination would always be 0°. However, the Earth is tilted by 23.45° and the declination angle varies plus or minus this amount. Only at the spring and fall equinoxes is the declination angle equal to 0°. $$ \delta = 23.45^{o} sin\left[\frac{360}{365}\left(d - 81\right)\right] $$

where d is the day of the year with Jan 1 as d = 1.

Elevation angle:

The elevation angle is the angular height of the sun in the sky measured from the horizontal. $$ α=sin^{−1}[sin\delta sin\phi + cos\delta cos\phi cos(HRA)] $$ Where $\delta$ is the declination angle, $\phi$ is the local latitude and HRA is the Hour angle.

Azimuth Angle:

The azimuth angle is the compass direction from which the sunlight is coming. At solar noon, the sun is always directly south in the northern hemisphere and directly north in the southern hemisphere. $$ Azimuth = cos^{-1}\left[\frac{sin\delta cos\phi - cos\delta sen\phi cos(HRA)}{cos\alpha}\right] $$

Where $\delta$ is the declination angle, $\phi$ is the local latitude and HRA is the Hour angle.

Zenith Angle:

The zenith angle is the angle between the sun and the vertical. The zenith angle is similar to the elevation angle but it is measured from the vertical rather than from the horizontal, thus making the zenith $$ Zenith = 90° - \alpha $$

Where $\alpha$ is the elevation angle.


Note that your input parameters are going to be:

  • Longitude
  • $\Delta T_{GMT}$ is the difference of the Local Time (LT) from Greenwich Mean Time (GMT) in hours
  • LT local military time in hours
  • $\phi$ the local latitude
  • d the day of the year
$\endgroup$
1
  • 1
    $\begingroup$ Thank you, this is exactly what I was looking for. A very clear and concise answer. $\endgroup$
    – Max Woolf
    Aug 7, 2014 at 11:53
0
$\begingroup$

I'm not sure if this is relevant for you, but it was for me. This will calculate true elevation, but it will not be the same as what is observed due to atmospheric refraction. There is a Meeus solar calculator and that uses this to correct for that: 1.02 / (60 * tan((alpha + (10.3/(alpha + 5.11))) * pi/180))

$\endgroup$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .