A drawing of my current situation
I am making a game that has a wraparound effect for some objects. The objects re-spawn at the opposite 'point' of the screen that they exit. I need to find this opposite point $(x_2, y_2)$ only given $(x_1, x_2)$, the velocity $(v_1, v_2)$ and the 'window size' $w \text{ width } , h \text{ height }$. Some other examples have been drawn in different colors.
I do have a working implementation of this, but it only works in the horizontal direction. I'd like to extend it to work at any angle. I have tried using the unit vector but I'm not sure what calculations to perform on it.
This can be done via modulo arithmetic:
$$x_2 = x_1 + tv_1 \pmod{w}$$
$$y_2 = y_1 + tv_2 \pmod{h}$$