The above code can be simplified as
if(v10>=0 && v1s<0){
tprime= v10*ts/(v10-v1s);
dtest = Math.abs(0.5*(ts-tprime)*v1s);
d1 = Math.abs(0.5*(v10)*tprime) + Math.abs(0.5*(ts-tprime)*v1s);
}else if(v10<=0 && v1s>0){
tprime= v10*ts/(v10-v1s);
dtest = Math.abs(0.5*(ts-tprime)*v1s);
d1 = Math.abs(0.5*(v10)*tprime) + Math.abs(0.5*(ts-tprime)*v1s);
}else{
d1 = Math.abs(0.5*(v10+v1s)*(ts-0));
}