"무한대"또는 "그림 8"궤적에서 개체를 어떻게 이동합니까?


28

포인트를 중심으로 객체를 이동하고 싶을 때 :

    point.x *= cosf(timer.timeElapsed);
    point.y *= sinf(timer.timeElapsed);

8 또는 무한대 부호 궤적에서 점을 이동시키는 방법은 무엇입니까?

답변:



61

As 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:

Lemniscate of Gerono animation

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:

Lemniscate of Bernoulli animation

(Animations made with Maple 13, compressed with GIFsicle.)


Thank you, everybody, for your support, which has earned me my first gold badge here on gamedev! :-)
Ilmari Karonen

1
+1 for not only posting the links, but also the formulas and graphics ( with sources ).
rootlocus

2
As is, this should be the accepted answer.
Brian H.

-1

I randomly found another one using this formula:

x2=y2+0.1x2.8

As plotted by Wolfram Alpha:

half of an infinity symbol


Unlike the other answers, this one is currently not presented in parametric form that lets us easily step the position forward over time t. I'd recommend including a description of how you would use this formula to position a moving object over time.
DMGregory

-4

((x+1)2+y2)((x1)2+y2)=1

half of an infinity symbol

The product of the distances from any point on that curve to (-1, 0) and to (1,0) is constant and equals to 1.


4
This answer provides a formula modelling such a curve, but not a method to "move an object" in such a way that it follows that curve. Please consider elaborating on the answer to indicate how you would use this math to move an object in a game.
DMGregory
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.