[solved]Tilted ellipse orbiting movement?

Get help using Construct 2

Post » Wed Mar 06, 2013 4:08 pm

Hi, I wonder if anyone know how to make a ellipse movement and tilted?




I know how to make a circle and standard ellipse. example:

Object.x = center.X+cos(time*300)*200
Object.y = center.Y+sin(time*300)*300porky2013-03-08 08:50:58
B
14
S
2
G
1
Posts: 94
Reputation: 2,089

Post » Wed Mar 06, 2013 4:24 pm

Have you tried taking the output of that, and then feeding into this, where a is the angle of tilt?

x = X cos(a) - Y sin(a)
y = Y cos(a) + X sin(a)cincipon2013-03-06 16:24:38
B
6
S
1
G
1
Posts: 70
Reputation: 702

Post » Wed Mar 06, 2013 5:03 pm

@cincipon, Do you mean x=center.x*cos(a)-center.y*sin(a) ?

Is there any constant or variable for orbiting speed?
B
14
S
2
G
1
Posts: 94
Reputation: 2,089

Post » Wed Mar 06, 2013 5:34 pm

He means this:

global number X = 0
global number Y = 0
global number a = 45

X = cos(time*300)*200
Y = sin(time*300)*300
Object.x = X*cos(a) - Y*sin(a) + center.x
Object.y = Y*cos(a) + X*sin(a) + center.y
B
79
S
24
G
54
Posts: 4,746
Reputation: 40,755

Post » Wed Mar 06, 2013 6:55 pm

https://docs.google.com/file/d/0B-6JjcHcczubZGc1RGtDbF9Dbnc/edit?usp=sharing

That should link to a capx demonstrating. t is the step, or speed, theta is angle of rotation, a is one axis of the ellipse, b is the other

The initial transformation I posted rotates about the origin, so this new one is corrected for that.

The parametric equation is:

X(t) = Xc + a * cos(t) * cos(theta) - b * sin(t) * sin(theta)
Y(t) = Yc + a * cos(t) * sin(theta) + b *sin(t) * cos(theta)

AND OMG I NEED TO REFRESH MY TRIG. Thanks for pointing out a glaring weakness of mine. :(cincipon2013-03-06 18:59:48
B
6
S
1
G
1
Posts: 70
Reputation: 702

Post » Wed Mar 06, 2013 10:39 pm

Thanks guys it works perfect! complicated and out of my brain though xD
B
14
S
2
G
1
Posts: 94
Reputation: 2,089

Post » Thu Mar 07, 2013 12:25 am

Don't sell yourself short! And also, trig is supremely useful in any video game development. Worth the investment of time if you're at all serious about making images move/stretch/rotate.
B
6
S
1
G
1
Posts: 70
Reputation: 702

Post » Sun Feb 09, 2014 5:03 pm

@cincipon - would you happen to be able to post a working example like you did before? That link leads to a file that has nothing to do with this question.

Is there anywhere on the web you could point me to where I could learn about more 'gamey' maths stuff like this? I know that I might be able to just copy and paste and fiddle to get it working, but I'd rather really understand the maths behind it!

Cheers.Psynaptik2014-02-09 17:29:56
B
5
S
1
Posts: 52
Reputation: 433


Return to How do I....?

Who is online

Users browsing this forum: Yahoo [Bot] and 0 guests