move point along a line

Hello, I'm writing some program on a basic vehicle simulator.
My vehicle currently compose of two points and from those two points I can calculate slope which can be use to determine the direction that the vehicle is heading.
I ran into problem of moving the vehicle forward. Is there any formula I move the vehicle forward in a direction or is there any other good way of doing this?
Thank
I'm not quite sure what the question is, but if you're calculating directions then your best bet is vector calculations.
Thank you for your reply,
Right now I have a vehicle, which is just two point in an x,y plane.
and I was trying to make it move forward along the line.
I was just messing with the sin cos stuff, and got it to work with some direction, but it can't go directly up and down since the slope is undefined. It can't also go backward.
Talking about, vector, Is it possible if you will be able to give some simple example on just how it work. I'll try and search online as well. Thank you again.
With vectors, the way you would represent the direction is what's called a "unit vector", a vector with a length of 1. If the direction vector has this property then you can use it like so:

1
2
3
4
5
//with individual components
posx += dirx*distance;
posy += diry*distance;
//with a vector class
vec_pos += vec_dir*scalar_distance;


In order to create a direction unit vector from an angle in standard position you would use this:

1
2
dirx = cos( angle );
diry = sin( angle );


And to get the direction unit vector of a vector, called "normalization":

1
2
3
length = sqrt(dirx*dirx + diry*diry); //Pythagorean theorem to get length
dirx /= length; //divide each dimension by the length, that will make the new length equal one
diry /= length;
Thank you very much for all the reply, I'll try it out.
Again Thank you so much.
Topic archived. No new replies allowed.