Displacement and Distance traveled logic in Easy java simulation.


Displacement = Displacement - Displacement_initial; // easy in EJS

I was wondering how to do this elegantly?

Distance_travel = Math.abs ( Displacement) ?? does not look correct


[b][color=blue][font=Verdana]Q1 :is there a

Distance_travel = Math.XXX ( Displacement) ? :)[/font][/color][/b]


or must i think of a  If ... else statement ???

if (Displacement < initial_Displacement) {
     statements          ;

it is a bit more complicated that i thought

}
else if (expr) {
     statements;
}
else {
     statements;
}

Reference:
http://en.wikipedia.org/wiki/Java_syntax#If_..._else