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: https://blog.demofox.org/2013/10/12/...tes-made-easy/