Determine objects direction

I’m working on a procedural rig and need to know the objects direction as it is being moved in the viewport.

This is what I have for it so far.
Download:
position02.ma

setup:
I have a single cone where the point is the direction.
An expression then controlls 2 locators, one that stays with the cone and one that lags behind.
The cone is then negatively aimed at the last locator to point in its direction.

Expression:

float $x1;
float $y1;
float $z1;

//
setAttr "pos01.translateX" $x1;
setAttr "pos01.translateY" $y1;
setAttr "pos01.translateZ" $z1;
//


$x2 = testCone.translateX;
$y2 = testCone.translateY;
$z2 = testCone.translateZ;

//
setAttr "pos02.translateX" $x2;
setAttr "pos02.translateY" $y2;
setAttr "pos02.translateZ" $z2;
//

$mag = sqrt(pow(($x2-$x1),2)+pow(($y2-$y1),2)+pow(($z2-$z1),2));

testCone.speed = $mag; 

testCone.test = (testCone.test+$mag);

$x1 = testCone.translateX;
$y1 = testCone.translateY;
$z1 = testCone.translateZ;

So as you drag the cone around you get the position you are moving in. Is this the right way to go about this? or is there a better cleaner way?

What I’m shooting for:

For each track on my robot rig i want a mechanism such as this to determine the speed for rotating the treads and the direction for detecting weather the tracks are going forward or in reverse.

Any help would be greatly appreciated.

Thanks!