While working on my game, I decided that I will at some point want to have line of sight for a unit. This is how I did it.
The game is on a hexagonal grid, so to make it easier, I decided that a circle around the outside of a hex is the size of whatever blocks vision. All I had to do was check each hex to see if it blocks vision, then for each of those hexes, mark all the ones behind them as invisible. What I was left with was a problem like this:
The unit is at A, the hex at B blocks vision, and everything further away than B that is between the yellow and red lines is invisible. So all I had to do was find the equations for the two lines. They turn out to be really elegant. After many pages of math where I made mistakes and relearned algebra, I found the two equations and plugged them into my map editor for testing. Anyone want to give it a try? I'll post the answer in the comments.
Here are the results!
A Small, Simple Map with a blocking hex and a unit:
Showing the LOS:
Yay it works. Here's a bigger example. This is supposed to be a cave interior, so the black is wall, the red is lava and the rest is just ground. The selected unit is in the middle.