Simply put, I have:

* A viewport rectangle where (0,0) is the bottom-left corner, (1,1) is the top-right and (0.5,0.5) is the centre of the screen.
* A point (a,b) which is outside of the rectangle.

This is in viewport coordinates so +X is right, +Y is up on the screen. 

And I need a function which takes these parameters and returns the point on the edge of the rectangle where the line (between the centre 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 down to code. Also, I realise questions like this have been addressed in different threads - but I can't find a simple input to output function anywhere.

I'm doing this in the Unity3D engine so preferably in Javascript but any language or pseudocode would be a great help as I can probably hand convert 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 of the circle and (x1,y1) is the intersection point.

Thanks