This doesn't have much to do with the

Java language specifically, but is a math problem encountered in the coding of my Java simulation.

So I am working on a simulation that allows you to set a vector of waypoints for a tank, which then drives to each of the points.

As of right now, it is all text based. Both the tank and a waypoint have two double coordinates: one for X and one for Y.

The tank starts at 0,0. The waypoint is defined by the user. Say the waypoint is (100,100). I would the tank to step incrementally towards the waypoint goal,

*in a straight line*. Each step would add to the tank's location X and Y.

The hard part is that I want this step to be a constant distance no matter how long the line from (0,0) to (waypointX, waypointY) is. I can do this as long as the slope is less than 1 with the following equations:

tankX = tankX + (CONSTANT_DISTANCE * (1 - (waypointY/waypointX) ) );

tankY = tankY + (CONSTANT_DISTANCE * (waypointY/waypointX) );

waypointY/waypointX is the slope of the line going towards the waypoint. But, if the slope >= 1, the equation no longer works properly.

The question: does anyone know of ONE equation that would increment the tank towards the waypoint regardless of whether slope is less than, equal to, or greater than one?

I'll keep scribbling in my notebooks and let you know if I get something, but if someone has encountered this problem before, that would be great.