'How to get 3D coordinates (XYZ) of the sun given Azimuth and altitude?
i'm creating a simple program that will simulate sunlight at a given time in the day. I am able to get the data { azimuth: -2.100262873246889, altitude: -0.01481415957435166 }
but not sure how to get the 3D coordinates out of it.
Here is my code:
import SunCalc from "suncalc";
const LAT = 68.148357;
const LNG = 9.996031;
const dateandtime = "2019-07-01T17:01:29.467Z";
var times = SunCalc.getTimes(new Date(dateandtime), LAT, LNG);
var sunrisePos = SunCalc.getPosition(times.sunrise, LAT, LNG);
Solution 1:[1]
x = R * cos(?) * sin(?)
y = R * cos(?) * cos(?)
z = R * sin(?)
Where R is the distance of the point from the origin, ? (the azimuth), and ? (the elevation).
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Md. Robi Ullah |