I am looking for an equation to calculate the parabolic curve between two points...or just a nice gradual curve that works would suffice!

Efforts so far have been far from perfect...

I am not using a behavior so just the maths will do...

Thanks.

10 posts
• Page **1** of **1**

I am looking for an equation to calculate the parabolic curve between two points...or just a nice gradual curve that works would suffice!

Efforts so far have been far from perfect...

I am not using a behavior so just the maths will do...

Thanks.

Efforts so far have been far from perfect...

I am not using a behavior so just the maths will do...

Thanks.

As long as I can move left, right and fire, I'm Happy...

**Posts:**655**Reputation:**12,260

B

42
S

15
G

11
With just two points all you exactly have defined is a line. You'll need three points to define a curve.

The standard formula for a parabola is the following:

y=a*x^2+b*x+c

Plugging in the x,y positions for the three points into the formula will give you three equations where the only unknowns are a,b and c. Then it's just a matter of using standard algebra to solve for the unknowns.

If that doesn't help, do you have more info about what you're trying to do?

In general the process is called curve fitting:

http://en.wikipedia.org/wiki/Curve_fittingR0J0hound 2013-06-24 18:46:22

The standard formula for a parabola is the following:

y=a*x^2+b*x+c

Plugging in the x,y positions for the three points into the formula will give you three equations where the only unknowns are a,b and c. Then it's just a matter of using standard algebra to solve for the unknowns.

If that doesn't help, do you have more info about what you're trying to do?

In general the process is called curve fitting:

http://en.wikipedia.org/wiki/Curve_fitting

**Posts:**5,073**Reputation:**57,880

B

85
S

27
G

85
@rojohound Thanks for the response,Ah the third point is probably what I'm missing...

I am trying to calculate the trajectory of a missile/artillery

I have the projectiles origin x,and the target x,the "ceiling" of the curve may have to be squashed down to keep it in the constraints of the layout,but if that is not possible I could probably work around that..

Your equation may help, however I am unsure how to calculate that third point...

Maths and algebra are not my strong point...

Again thanks...Pixel perfick 2013-06-24 19:23:19

I am trying to calculate the trajectory of a missile/artillery

I have the projectiles origin x,and the target x,the "ceiling" of the curve may have to be squashed down to keep it in the constraints of the layout,but if that is not possible I could probably work around that..

Your equation may help, however I am unsure how to calculate that third point...

Maths and algebra are not my strong point...

Again thanks...

As long as I can move left, right and fire, I'm Happy...

**Posts:**655**Reputation:**12,260

B

42
S

15
G

11
This topic is relevant:

http://www.scirra.com/forum/parabola-tracjectory-tracing-with-physics-box2d_topic61895_page2.html

But you're right it does use the physics behavior so here is a capx the behavior replaced by four actions:

https://dl.dropboxusercontent.com/u/5426011/examples18/proj_path_no_phys.capx

It has the math worked out so the initial launch angle points somewhere above the target and from that a speed is calculated so the target is reached. It's a sightly different approach than what I outlined before. The initial angle can be anywhere in the range of the angle to the target and straight up.

http://www.scirra.com/forum/parabola-tracjectory-tracing-with-physics-box2d_topic61895_page2.html

But you're right it does use the physics behavior so here is a capx the behavior replaced by four actions:

https://dl.dropboxusercontent.com/u/5426011/examples18/proj_path_no_phys.capx

It has the math worked out so the initial launch angle points somewhere above the target and from that a speed is calculated so the target is reached. It's a sightly different approach than what I outlined before. The initial angle can be anywhere in the range of the angle to the target and straight up.

**Posts:**5,073**Reputation:**57,880

B

85
S

27
G

85
@rojohound Thanks for taking the time to help, I really appreciate it...

This pretty much covers exactly what I wanted...

One question though,and apologies as I failed to mention this in my initial post, how would I get the object to fix it's angle to the blue line, like a javelin?

Again many thanks for this...

This pretty much covers exactly what I wanted...

One question though,and apologies as I failed to mention this in my initial post, how would I get the object to fix it's angle to the blue line, like a javelin?

Again many thanks for this...

As long as I can move left, right and fire, I'm Happy...

**Posts:**655**Reputation:**12,260

B

42
S

15
G

11
While there are ways to calculate the slope on any point on a parabola I find a simpler method is to save the old position of the objects and set the angle from the old to current position. The event would look like this:

+every tick

set angle to angle(self.old_x, self.old_y, self.x, self.y)

set old_x to self.x

set old_y to self.y

This method has the added benefit that it can be used with any motion.

+every tick

set angle to angle(self.old_x, self.old_y, self.x, self.y)

set old_x to self.x

set old_y to self.y

This method has the added benefit that it can be used with any motion.

**Posts:**5,073**Reputation:**57,880

B

85
S

27
G

85
10 posts
• Page **1** of **1**

## Who is online |

Users browsing this forum: blackhornet, RetroSpock and 14 guests |