bit of 2D maths help: travel Arc between two points?

Hello,

I have a problem and I’m not smart enough to work out a solutions. Plus a company delivered my item to the wrong door and say its my fault…? so a bit stressed!!!

anyway,

I want to achieve a throw, a bomb between two points, and so it travels as an art from point A, to point B.

My idea was:
Use half a circle, but cant even seem to get circle right today,
Then just stop after 180 deg… (or the degrees between the points, which I didnt work out yet?)
The points are not on a 180Deg plane. but one may be higher than the other.

…Make a circle…which is playing up?! I cant even get that right! I thought maybe the coords system? .

UNITY x, y are x, y
my coords are ( 0, 0 ) is top left. (helps for my tiles mapping)…

This is what I have been playing with for hours, , 
    		Vector3 centre = bombPosition; //= ( bombPosition + ( distance / 2 ));
    	//	centre.x = ( bombPosition.x + ( distance.x / 2 ));
    		//centre.y = ( bombPosition.y + ( distance.y / 2 ));
    		
    		for(float wait = 1; wait <= (  Mathf.PI ) ; wait += 0.1f)
    		{
    			Debug.Log(wait);
    			
    			yield return new WaitForSeconds (0.5f );
    			//float deg = wait * Mathf.Rad2Deg;
    			
    			//deg = wait * (2.0f * Mathf.PI / wait);
    			
    			bombPosition.x = centre.x += ( 60 * Mathf.Cos ( (float) wait )  );
    			bombPosition.y = centre.y -=  ( 60 * Mathf.Sin ( (float) wait)  );
    			
    			bomb.transform.position = bombPosition;
    		}

Rather than use a circle, how about some simple particle physics? Let’s imagine the object starts of at t =0 at the origin and this is point A (it could really be anywhere, just apply the translation you need), similarly we’ll imagine that the point B is aligned along the x axis (a rotation will make this true, so we’re not losing this by picking a coordinate system). If the vector AB is a horizontal distance, d, away from the object and we throw it such that its horizontal speed is v_h then it will have reached the spot B (or its horizontal position) at a time

t = d / v_h

Ok. So we should throw it with an initial vertical velocity v_v, chosen such that it is magically at the right elevation at that moment. Let the difference in height between A and B be equal to h and the acceleration due to gravity be g. Measuring from A’s position the height at time t will be:

s = v_v. t - 0.5. g . t^2

Rearranging a bit:

v_v = (0.5.g.t^2 + s) / t

Since we’ve already figured out how much time we have available to us for this arc, we’ve now calculated what the initial velocity should be. Back in the land of code, if we maintain a timer then we can use this to drive the bomb along this curve.

A few clarifications on my notation:

  • When I use an underscore, it should be read as an subscript, so ‘v_v’ is a shorthand for ‘vertical velocity’
  • The caret ‘^’ should be read as a superscript or power, so t^2 is t squared (t * t)
  • ‘s’ is a distance, in the context of the final formula it should be interpreted as a vertical distance that the object is moving through.
  • ‘g’ is acceleration due to gravity in the downward direction, so for objects moving in an earth-like environment a value of 9.8 m/s^2 would be fine.

oh interesting, thank you

Was reading here and as you say, realized maybe the circle is the wrong approach and more like I’m needing a “parabolic arc”

I don’t have time for the next days to read through your answer properly. At quick glance, I am a little confused by the format of the equation.

v_v = (0.5.g.t^2 + s) / t

May I ask, whats the _ represent?

and .'s?, What do they represent? +?

also I’m not sure what g is? 0.5 (.?) g - gravity?

v_v ?

http://www.mathworks.com/matlabcentral/newsreader/view_thread/278048

Thanx for the hints, check back in 3 days :slight_smile:

thank you,

I do however have a question,

if the distance between the two positions AB is dynamic and the horizontal distance changes, the vertical distance may also change.

How can we know the initial vertical velocity in which to throw the object to make it art exactly on to position B?

for normalised distance: distance x= 0 to 1, height y= 0 to 1

rising half x(0to0.5): y = (x2)/(x2) because for (0 to 1)/(0 to 1) is an a rising arc

falling half the same in reverse. when object gets half way, change formula from first to second. perfect parabol. or just look for parabola also and strech one out and reverse it:

PARABOLA FORMULA:
https://www.google.co.uk/search?hl=en&q=parabole&biw=1184&bih=593&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&um=1&ie=UTF-8&tbm=isch&source=og&sa=N&tab=wi&ei=9aCDUN-qKMiYhQfhnIDIDQ#um=1&hl=en&safe=off&tbm=isch&sa=1&q=parabole+formula&oq=parabole+formula&gs_l=img.3..0i10i24.6886.8770.0.8998.8.8.0.0.0.0.647.1108.0j1j1j5-1.3.0...0.0...1c.1.m3lDZEwsCh0&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&fp=1a27f3257e169672&bpcl=35466521&biw=985&bih=650

and you could easily adapt the 3rd parabola on this page, simply move it forwards by one space and multiply will divide the height by an amount required and the distance also.

http://www.tutorcircle.com/common-graphs-tbjup.html

for normalised distance: distance x= 0 to 1, height y= 0 to 1

rising half x(0to0.5): y = (x2)/(x2) because for (0 to 1)/(0 to 1) is an a rising arc

falling half the same in reverse. when object gets half way, change formula from first to second. perfect parabol. or just look for parabola also and strech one out and reverse it:

PARABOLA FORMULA:
https://www.google.co.uk/search?hl=en&q=parabole&biw=1184&bih=593&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&um=1&ie=UTF-8&tbm=isch&source=og&sa=N&tab=wi&ei=9aCDUN-qKMiYhQfhnIDIDQ#um=1&hl=en&safe=off&tbm=isch&sa=1&q=parabole+formula&oq=parabole+formula&gs_l=img.3..0i10i24.6886.8770.0.8998.8.8.0.0.0.0.647.1108.0j1j1j5-1.3.0...0.0...1c.1.m3lDZEwsCh0&pbx=1&bav=on.2,or.r_gc.r_pw.r_cp.r_qf.&fp=1a27f3257e169672&bpcl=35466521&biw=985&bih=650

modify the 3rd Formula on this page, in total you will have a 2 line simple arc formula
http://www.tutorcircle.com/common-graphs-tbjup.html

Okay square root is not ideal for an arc, but it’s good to know to shape control signals, probabilities of monsters appearing, distance to speed variables etc