I am doing some image processing and let us say that I have a point (e.g. (1000, 1000)) and an angle (e.g. 30 degrees), and I need to figure out at what point will I touch the border of the image (0, y) or (0, x) if I walked from that point at given angle. I can do it iteratively by just doing through an iterator and walking one step at a time, by doing in this example:
for i in range:
x = 1000 - i * cos(30)
y = 1000 - i * sin(30)
but maybe there is a better way to straight up find at which point will I hit the image border?
I added image for clarity.