# Working out destination from starting point, angle and power

• May 4th 2009, 07:40 AM
Gaz_j03
Working out destination from starting point, angle and power
Bit of a strange problem and I hope i've posted in the correct place.

I am writting a computer game (very basic golf) I have three sliders I can set:

Power(0-100)
Angle (-90 - 90)
Start position of ball(represented in the code by an x and y co-ordinate)

after each is set, then I hit the button "SHOOT"

I want to know how I can work out the vector from the above (the change in x, and the change in y)

Although it is for a game its the same principle as paper. Imagine a top down view of a piece of graph paper with each line being numbered along the x axis and same on the y

Any help would be really appreciated greatly
• May 5th 2009, 07:02 PM
billa
Hopefully I can help

First of all I am going to assume that you have some kind of maximum velocity constant for your ball.

The vector you want would probably be...
dx = (power/100)*Maximum_Velocity*cos(angle)
dy = (power/100)*Maximum_Velocity*sin(angle)

That would be the velocity vector and you would add it to the position vector

Tell me if this works. I used to program games so I might be able to help if you need anything else.
• May 19th 2009, 02:26 PM
Gaz_j03
I'm not very familiar with vectors. When i read it I assumed i'd take the dx value and dy value and add them to x and y representing the current position of the ball? But this does't work.

The figures output are nowhere near so i think i misunderstood you, sorry. Could someone clear this up?