When I want to move object around point I do:
point.x *= cosf(timer.timeElapsed);
point.y *= sinf(timer.timeElapsed);
How to make point move on eight or infinity sign trajectory?
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It only takes a minute to sign up.
Sign up to join this communityAs Marton notes, there are several "figure of eight" curves that might fit your needs. Perhaps the simplest is the lemniscate of Gerono, which has the parametrization:
x = cos(t);
y = sin(2*t) / 2;
and looks like this:
However, the lemniscate of Bernoulli may be visually more pleasing; it has a parametrization very similar to the lemniscate of Gerono, except that both axes are scaled by a factor of 1/(sin(t)^2 + 1) = 2/(3 - cos(2*t))
:
scale = 2 / (3 - cos(2*t));
x = scale * cos(t);
y = scale * sin(2*t) / 2;
It looks like this:
(Animations made with Maple 13, compressed with GIFsicle.)
I randomly found another one using this formula:
$$x^2 = y^2 + 0.1x^{2.8}$$
As plotted by Wolfram Alpha:
t
. I'd recommend including a description of how you would use this formula to position a moving object over time.
\$\endgroup\$