I couldn’t find this question here although it seems simple.
lets say that I want to calculate the percentage of an overall distance when i know the start and end positions ie:
function getPercentage(startpos,endpos,currentpos)
{
var distance = endpos-startpos;
return (currentpos/distance)*100;
}
easy, but it’s very late an coffee’s not working what happens if the startpos or the current pos is in the negative axis i.e.
startpos = -734;
endpos = 65;
currentpos = -38;
worth noting that any position could be either in positive or negative axis at any point.
what percentage of the distance is the currentpos at….
Can anyone throw me a bone pleasee it’s 1am 🙂
You forgot to translate the current position as well.