Move Object allong an ellipsoid path


I'm new to Unity and whats even worse for this case of situation, not that good in mathematics :).

So my problem is, I want to move an Object with the cursor keys (left, right) or with a gamepad allong an ellipsoid path on the screen.

The screen center is also the center of the ellipse. The object should always look to the center of the ellipse (ok, I already know how to do that).

So can anybody with mathematical magic fingers tell me how the calculation for the position of the object that should move along the ellipse is?

An example script would be welcome. I'm planning to use c#, but a js script would just be as fine.

Thx alot, K

more ▼

asked Sep 18 '10 at 08:47 AM

KrisF gravatar image

61 2 2 3

(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

The mathematics is pretty simple, have a look at wikipedia.

You need to define your ellipse with a few parameters:

x, y: center of the ellipse
a, b: semimajor and semiminor axes

If you want to move on the elipses this means that you change the angle between the major axes and your position on the ellipse. Lets call this angle alpha.

Your position (X,Y) is:

X = x + (a * Math.cos(alpha));
Y = y + (b * Math.sin(alpha));

In order to move left or right you need to increase/decrease alpha and then recalculate your position.

more ▼

answered Sep 18 '10 at 04:02 PM

Wotan gravatar image

97 3 3 10

(comments are locked)
10|3000 characters needed characters left

Thank you very much. It works just fine now :)

more ▼

answered Sep 20 '10 at 10:43 AM

KrisF gravatar image

61 2 2 3

Sep 20 '10 at 11:51 AM Herman Tulleken
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments



asked: Sep 18 '10 at 08:47 AM

Seen: 5035 times

Last Updated: Sep 18 '10 at 08:47 AM