1. ## Algorithm needed!

Hi,
I am currently working on a program that governs nautical navigation by warships and encomposes many simple geometric algorithms that assist ships in finding courses, distances and speeds to different points in space. (in my case, ocean).

My question is as follows:
I need to create algorithm which will take the distance to the point travelled to and the ship's deceleration and current speed and will return the distance from the destination in which the ship should start decelerating in order to reach it's destination exactly.

I know it's a simple problem but I'm after about 8hrs of programming and have reached a blank in thought... I will appreciate pseudo code but please NO C++ CODE

Thank you,
Warlax

2. given a decelaration a [m/sec2] and the current speed v [m/sec] you can calculate the time to stop as t = v/a.
from the time you can calculate the distance as d = v/2 * t.
Kurt

3. Rearrange t = v-u/a
then
0.5*t*a

4. You just got there before me.

5. ## Nope

This doesn't help
Let me refine my question a little further:

I have a ship that has a max. speed of M (mtrs/sec) and a current speed of V (mtrs/sec). It is able to accelerate or decelerate at a rate of A (mtrs/sec per sec). I also have my distance to destination given...

I need two things:
a) an algorithm which will set the proper speed towards the destination, taking into account the possibility of the destination being to close to the ship's initial point of departure to allow it to gain full speed before it needs to start stoping.

b) an algorithm which tells me when to start decelerating the ship towards a stop.

* I am not interested in just stopping the vessel from it's speed to zero, as it is not realistic.
** I do not wish to overshoot my destination, creating a situation in which my ship will continue to plan new courses to try to re-hit the target over and over again.

Thank you.

6. I don't think that stopping a ship from current speed to zero is necessarily unrealistic - besides, 0 is a nice number with which to do this kind of simple modelling using vectors... zero allows you to factor out "final velocity" from equations of motion.

that would make your 'knowns' as follows:
Code:
```u:  "initial velocity" (m/s) = ships max. speed
v:  "final velocity" (m/s) = 0 - ship isn't moving anywhere (maybe the anchor is down?)
a:  "acceleration" ( (m/s)/s ) = a negative value - how fast your ship is decelerating```
as someone already said, you can find the time it takes to stop with
Code:
`a = (v-u) / t`
rearranged to
Code:
`t = (v-u) / a`
then displacement can be calculated with
Code:
`s = (1/2)*(v+u)*t`
legend:
Code:
```s:  "displacement" (m)          t:  "time" (s)
u:  "initial velocity" (m/s)    v:  "final velocity" (m/s)
a:  "acceleration" ( (m/s)/s )```

I don't know what you mean by "Proper speed to its destination" if a ship is decelerating, then its velocity is constantly changing.

7. This is simple maths, once you know the relevant equations.
http://www.physchem.co.za/Graphs/Equations.htm

Take an appropriate one, rearrange it to find out what you want, from what you know and apply.