• Advertisement
Sign in to follow this  

Making a curve path from one point to the other

This topic is 3657 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, Let's imagine i have a point, (x,y) and i want to send a projectile(cannon type) from this (x,y) point to another point (x1,y1). Something like this (x,y) (x1,y1) How can i make a point travel between this two points ? thanks

Share this post


Link to post
Share on other sites
Advertisement
Either use 'real' physics to simulate the projectile's movement or look into Catmull-Rom splines to interpolate between the two points.

Share this post


Link to post
Share on other sites
You need to be clear on what the difficulty is.

Do you have options but not know which one to take, Struggling to write actual code or lack the physics knowledge to predict this movement.

I'll help a bit with the latter giving you the most basic equations and a link if I can find a page on basic mechanic/dynamics.

Lesson 6 is the easiest way to model such motion and is pretty accurate. Unless your actually designing a simulator I don't see much point in considering all the rest of the dynamics involved in firing a projectile. I know it only covers 1-D but movement in the x and y direction are independent of each other. So as long as your trig is ok you should be fine.

Someone could probably right you a function for this in a couple of minutes but that wouldn't help you with similar problems in future.

Share this post


Link to post
Share on other sites
Well with your current constraints you theoretically have an infinite number of possibilites that meet the criteria. But the equations you need are these.

Y = Y0 + VY0*t - 1/2*g*t2
X = X0 + VX0*t

VX0=cos(angle)*V
VY0=sin(angle)*V
(assuming an angle of 0 points right and moves counter clockwise as angle gets bigger)

So you need to constrain the launch angle somehow. You will need to figure out how you want that handled.

Once you get that you just need to solve for V using the equations

V=sqrt((g*(X-X0))/(2*cos2(angle)*(tan(angle)*(X-X0)-(Y-Y0))))

Then you can plug V back into
VX0=cos(angle)*V
VY0=sin(angle)*V

To get the initial x and y velocities.

Note:
g - is the strength of gravity as a positive value
Y - y1
X - x1
Y0 - y
X0 - x
angle - the launch angle

EDIT: I am not going to remove my solution, but I do agree with ramearess. This is not a hard problem once you have an understanding of the math behind what you are doing. Maybe you should go ahead and work through the problem on your own anyway.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement