I am implementing a 2D football game. For my pass algorithm, I calculate the slope between the passer and reciever with the equation m = (y2-y1)/(x2-x1)
In some conditions x2 and x1 are equal resulting in a divide by zero exception. What should I do in this case?
I did not ask this question on math.stackexchange.com because it’s a programming question.
Don’t use the slope of a line for this sort of operation, for just the reason you have stumbled across. Use instead the angle of the line from passer to passee. Apply a little trigonometry. If that little trigonometry is beyond you, delete this question, do some work, then post again when you get stuck again.
EDIT
I suggest you use trigonometry for 2 reasons.