Read more: Transforming between coordinate systems
import math
def sphericalcoord(r, theta, phi): # altitude, longitude, latitude
x = r * math.sin(theta) * math.cos(phi)
y = r * math.sin(theta) * math.sin(phi)
z = r * math.cos(theta)
return sphere_x, sphere_y, sphere_z
def cartesian_to_spherical(x, y, z): # z is up
r = math.sqrt(math.pow(x, 2) + math.pow(y, 2) + math.pow(z, 2))
theta = math.acos(z / r)
phi = math.atan(y / x)
return r, theta, phi
Using Numpy implementing from The sun's position in the sky.
import numpy as np
import math
spherecoord = np.array([r * math.sin(theta) * math.cos(phi),
r * math.sin(theta) * math.sin(phi),
r * math.cos(theta)])
t = 0 # time
ecliptic = np.array([math.cos(t), math.sin(t), 0])
ecliptic.reshape(3, 1)
ecliptic = np.matrix(ecliptic)
epsilon = math.radians(23.44) # earths tilt in radians
axialtilt = np.array([1, 0, 0,
0, math.cos(epsilon), math.sin(epsilon),
0, math.sin(epsilon, math.cos(epsilon))])
axialtilt.reshape(3, 3)
axialtilt = np.matrix(axialtilt)
equatorial = axialtilt * ecliptic
A sidereal day is the time it takes for earth to make one revolution around it's axis of rotation so the stars line up in exactly the same place they started in the sky from one sidereal day ago.
Modulo etc for timekeeping.
Interpolate between three data points.