I am really not able to create a "point" (straight with an angle starting at a specific point) rectangle intersection to find the intersecting points (using JS). Just found out it's called "ray", so I edited the title.
I read so much about it and found many solutions for line/line intersections and line/rectangle intersections etc.
In my case, I don't have a line with start and endpoint, but a point with a given angle from which there needs to be a line till the intersection point.
Later on, the line should only be visible in the inner auf the rectangle, that's why I need the intersection. The rectangle is always axis-aligned.
I have no idea how to get that intersection because of the many cases (point in rectangle, point out of the rectangle, negative values). And I never worked with vectors.
I created an image to make it clearer:
Any ideas on how to get the intersection points?
Probably I have to start testing every line of the rectangle against my straight line. But I even don't know how to check that...
Thank you so much for your help!
y = kx + b
) using trigonometric functions, then an intersection occurs atRect(x) - Line(x) === 0
.