Useful method if you’re given a sun position as azimuth and elevation, or for other spherical to cartesian conversions (cameras, etc.)
X = cos(theta) * cos(phi) * radius
Y = sin(theta) * cos(phi) * radius
Z = sin(phi) * radius
Reference: Converting To and From Polar / Spherical Coordinates Made Easy « The blog at the bottom of the sea