Rotating a directional light 360 degrees about a single axis

I have some code:

' Update solar light source direction.
SolarPosition[0] = Unknown
SolarPosition[1] = 0
SolarPosition[2] = 1
SolarPosition[3] = 0
Gl.Lightfv(Gl.LIGHT0, Gl.POSITION, SolarPosition)

I realize that a directional light uses a vector to determine its direction but can’t figure out what values should be used to make it spin continuously about one axis, simulating the sun. I can get it to bounce between what appears to be a 180 degree arc, but I can’t get it to a full cycle. Experimental values produce illogical results. What am I missing here?

Post your rotation math pls. The stuff you posted is merely what you want to do after calculating the new, rotated direction.

This seems to work:

  Dim cs As Single
  Dim sn As Single
  Dim x As Single
  Dim y As Single
  Dim px As Single
  Dim py As Single

  ' Calculate solar direction vector.
  cs = Cos(Rad(360 - SanctimoniaOrientation + 90))
  sn = Sin(Rad(360 - SanctimoniaOrientation + 90))
  x = 0
  y = 1
  px = x * cs - y * sn
  py = x * sn + y * cs

  ' Set solar light source direction.
  SolarPosition[0] = py
  SolarPosition[1] = 0
  SolarPosition[2] = px
  SolarPosition[3] = 0
  Gl.Lightfv(Gl.LIGHT0, Gl.POSITION, SolarPosition)

Some notes: I inverted the Y axis with a modelview matrix scale transformation and SanctimoniaOrientation is the axial orientation of the planet where noon is at 180 degrees and midnight is at 0/360 degrees.

Let me know if you need more help with these sorts of things, as I know math isn’t your strong suit. Good luck with your project!

Let me know if you need more help with these sorts of things, as I know math isn’t your strong suit. Good luck with your project!

Ehm … what? :confused:

Just a sad attempt at humor, or at least being passive-aggressive. Ignoring all that, I hope the code I came up with is reasonably correct for my purpose.