Suppose an object is moving in some direction on a 2D plane. Its direction is given as a heading, where 0 degrees is north and 180 degrees is south.
Suppose that I know the object's coordinates are 0,0 (x,y) and that its heading is 90 degrees. To maintain the current heading I know that for each whole unit I move the object along the X-axis I need to move it 0 units along the Y-axis.
But suppose the same object's heading changes to anything else, like 98 degrees. How would I determine how many units to move in each direction to maintain the current heading, where either X or Y must move a whole unit (but not necessarily both)?
I suppose the question I am asking is similar to "how do I find another point given a point and slope", but the slope is in degrees and I can't figure out how to convert that.
Here is a function and expected output if it helps clarify:
f(x,y,d) = a,b (where a and b, when added to x and y, are the next point on the line in the direction of the heading)
f(0, 0, 0) = 0,1 (heading north, so for each 1 unit added to Y we add 0 to X)
f(0, 0, 45) = 1,1
f(0, 0, 90) = 1,0
f(0, 0, 135) = 1,-1
f(0, 0, 180) = 0,-1
f(0, 0, 225) = -1,-1
f(0, 0, 270) = -1,0
f(0, 0, 18) = a,b
f(0, 0, 200) = a,b
f(0, 0, 65) = a,b
Either x or y needs to be a whole number, but one of them can be a decimal number. For example, to move x 1 point, move y 0.345 points, or vice versa.
The function $f$ you describe is
$f(x,y,a)=(x,y)+\begin{cases} (1,\cot (a)) & 45\leq a\leq 135 \\ (-\tan (a),-1) & 135\leq a\leq 225 \\ (-1,-\cot (a)) & 225\leq a\leq 315 \\ (\tan (a),1) & \text{else} \end{cases}$
which is well-defined despite the overlapping conditions.