2.5d game render math problem So I'm making a star Ship bridge game where the game is rendered using a 2-D Cartesian grid for positioning logic. The player has only the attributes of position and an arbitrary look-at angle (currently degrees). A "view-port" determines if a planet is within the angular difference of $45^\circ$ so that it can render the planet. My problem is finding the formula in order to find the appropriate x-coordinate on the "view-port". So far I have         
$x = \frac{\text{View Width}}{2} - \frac{\text{View Width}}{2}\times (\text{Angular Difference})$
where angular Difference is converted to a rational number between 0.0 and 1.0 and can be negative or positive

 A: *

*You might want to consider using vectors, view matrices, and all the paraphenalia of conventional computer graphics to do this. In the end, it'll be easier, I promise. 

*I'm going to do my best to answer the question that I think you're asking. You're looking in some direction, specified by an angle. (It seems to me that you should have TWO angles. If you imagine a huge latitude-longitude grid imposed on the celestial sphere, you need to know both the latitude and longitude of the point at which your gaze is fixed. But let's ignore that for a moment.)  You're looking at some planet as well, and you have an angular position for that planet. And somehow you've computed an angular difference between your gaze direction and the direction to the planet. Let's call that angular difference $d$, OK? You're planning on displaying the planet on a screen whose width is $ViewWidth$. If the angular distance is no more than 45 degrees, you want the planet to show up on screen, but you need to know where. 
What you've done so far is to assume that the offset from the center of the view is proportional to the angle. It should, however, be proportional to the tangent of the angle. 
Before I explain what to do next, I'm going to say one more thing: you should imagine your viewport on your view plane as having coordinates that go from $-1$ to $1$ (left to right), with $0$ at the center of your gaze. (Similarly for up and down, of course). Then when you need to convert to pixel coordinates, you do this:
xPixel = minXPixelCoord + (2*u - 1) * xPixelWidth
so that as $u$ ranges from $-1$ to $1$, xPixel ranges from minXPixelCoord to 
minXPixelCoord + xPixelWidth  (the latter being the width of the window on screen, meansured in pixels). Typical values might be minXPixelCoord = 100; xPixelWidth = 800. 
OK, so how do we compute $u$, the view-port coordinate that ranges from $-1$ to $1$? 
$$
u = \tan(d) 
$$
where you have to use a tangent function that takes in degrees. Most computer-based ones use radians, in which can you'd write
$$
u = \tan(\pi d / 180 ).
$$
Notice that this will only work if the angular distances when the planet is to the left of your gaze are negative numbers, and the ones where the planet's to the right are positive numbers. 
A: Does your language have an Atan2 function?  It takes two coordinates $y$ and $x$ and returns the angle from the positive x axis of the point.  The result is in radians, so if you want degrees you need to multiply by $\frac {180}{\pi}$  You can check the angle to the planet against the angle to the center of the view port$\pm$ half the width.  The nice thing is that it handles the ambiguity in quadrant of the usual arctangent.  You still have to worry about crossing $0/360$ degrees because $350$ degrees is within $22.5$ of $10$ degrees.
