Simply put, I have:
- The rectangle of the viewport, where (0,0) is the lower left corner, (1,1) is the upper right corner, and (0,5,0,5) is the center of the screen.
- A point (a, b) that is outside the rectangle.
This is in the coordinates of the viewport, therefore + X is right, + Y is on the screen.
And I need a function that takes these parameters and returns a point on the edge of the rectangle, where the line (between the center of the rectangle (0,5,0,5) and the point (a, b)) intersects it.
I know how to do this on paper with given coordinates, but I just can't figure it out when it comes to code. In addition, I understand that such issues have been addressed in different threads, but I cannot find a simple input for the output function anywhere.
I do this in the Unity3D engine, so it is desirable in Javascript, but any language or pseudo-code will be a big help, since I can probably pass it.
EDIT
To clarify, I'm looking for something like:
function IntersectFromViewportCenter(x : float, y : float) {
...
return Point(x1, y1);
}
Where (x, y) is the point outside the circle and (x1, y1) is the intersection point.
thank
jt78 source
share