Transposing an object from one point to another

Hi,

I am writing a traffic simulation with path finding based on the A* algorithm. The A* algorithm returns a vector list of a struct Vector3 (made up of 3 float values - X,Y,Z), the first of the list being the starting node(position), and the last element of the list being the end node(goal position).

I have a class car which takes a vector3 as an argument, and initializes the position. The car class has a method draw car, which translates to the car position and draws a glutsolidcube. this method is called continuously within my renderscene method which is the argument of the glutDisplayFunc.

I’m wondering what is the best way to update the position iteratively to each position returned by the algorithm.


class Car
{
public:
	Vector3 position;
	Vector3 velocity;
	double size;
	float maxSpeed;
	Graph graph;
	vector<Connection> currentPath;
	bool finishedPath;

	Car(Vector3 initialPos, Graph g)
	{
		finishedPath = false;
		graph = g;
		size = 5;
		position = initialPos;	
		currentPath = PathFindAStar(graph,0,4,Heuristic(4));
	}
	void DrawCar()
	{
		int time = glutGet(GLUT_ELAPSED_TIME);
		glTranslatef(position.X, position.Y, position.Z);
		glutSolidCube(size);
		Update(time, nodePositions[currentPath.at(0).GetToNode()]);	
	}
		
	void Update(int time, Vector3 nextTarget)
	{

	}	
};

Thank you

You can easily start with linear interpolation, then depending on the situation try something smoother like Hermite, Bézier, spline, …

The idea is to take previous and current A* predicted positions, and linearly interpolate depending on elapsed time and desired speed.