Because the disadvantages of the Octogrid make it nearly impractical to implement, I next went back to thinking how to make a square grid work realistically with 8 directions. Shortly after, I decided that perhaps simple formulas could be developed to allow full 360-degree simulation. Time to recall high school trigonometry.

After a lot of tinkering and calculations by spreadsheet, I've developed a template and generic formula for determining if a **target** square on a square grid is "within range" of a **source** square. I don't yet have a slick name for the system, beyond the descriptive **Square Grid enhanced with trigonometry** or simply **Square Grid With Trig**.

*reachable*from the white "source square" for range values 1-10. Only angles 0-45 degrees are depicted; flipping and/or rotating the chart allows it to be applied to any case within 360 degrees.

For ranges greater than 10 (or possibly fractional), a calculator needs to be used with the following formula. The following two diagrams are mathematically equivalent, designed to show how cell counting can provide the inputs needed for the formula. As with the chart above, flipping and/or rotating these depictions allow for any situation.

or

** What's important to remember** is that when counting the cells (squares) from the source to the target, the bigger number (i.e. the longer side of the right triangle that is formed) is assigned to $m$, and the smaller is assigned to $n$.

To determine which cell ($m^{\prime}, n^{\prime}$) along the ray in the direction of the target from the source (e.g. the red arrow in the diagrams above) is the farthest extent for a range value of $k$, use the following formulas:

(1)If $m^{\prime} > m$ **or** $n^{\prime} > n$, then the target is out of range.

If $m^{\prime} \leq m$ **and** $n^{\prime} \leq n$, then the target is within range.

# Example

TODO

# Line-of-sight

The next thing to figure is arbitrary *line-of-sight* formulas to determine if an occupied square is "in the way" between the source and the target.

TODO