Circular path based on time (sun's path in sky)

54 Views Asked by At

I'm working on a video game and have coordinates:

  • z is West (negative) and East (positive)
  • y is elevation

I'm trying to find an equation for each part of the sun's position (z, y) so that it rotates around a center (0, 0) based on the time.

At minute = 0, it will be rising in the East (positive Z coordinate), continue in the air, updating based on time, until it reaches minute = 3, where it will set in the West (negative Z coordinate).

  • minute = 0: (3000, 0)
  • minute = 1.5: (0, 3000)
  • minute = 3: (-3000, 0)

If you have any ideas, they're all appreciated!

circle diagram

1

There are 1 best solutions below

0
On BEST ANSWER

To achieve what you want, just consider the equation $z^{2}+y^{2} = 3000^{2}$

Let $y = r\sin \theta, z = r\cos \theta$

Now we want it to vary with period $3$ rather than period $2\pi$.

So at $\theta = \frac{\pi}{2}$, $t=1.5$

Therefore let $t=\frac{3\theta}{\pi}$

So we get $\theta = \frac{\pi t}{3}$

$\Rightarrow y = r\sin(\frac{\pi t}{3}), z = r \cos (\frac{\pi t}{3})$

So let $r = 3000$

Then our equation fits the first equation: $z^{2}+y^{2} = 3000^{2}(\sin(\frac{\pi t}{3})^{2} + \cos(\frac{\pi t}{3})^{2}) = 3000^{2}\cdot 1 = 3000^{2}$ as required.

So the solution is:

$y = 3000 \sin(\frac{\pi t}{3}), z = 3000 \cos (\frac{\pi t}{3})$