3

The equation of an elliptical path can be defined as:

x^2 / (240/2)^2 + y^2 / (h/2)^2 = 1

Where h = a randomly generated height between 10 and 60.

And t = time in seconds elapsed.

How can I start at a specific point when t = 0, and follow along the path as t increases, looping indefinitely?

Joncom
  • 1,985
  • 1
  • 18
  • 29

1 Answers1

7

It's actually easier than that. Position on an elliptical path over time is:

x = Math.cos(t)*w/2
y = Math.sin(t)*h/2

With w and h the width and height, respectively. Scale t as needed to get the speed you want.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592