Develop viewshed algorithm enablers
- Research into interpolation methods
- Devlopment and testing of Linear interpolation and Bilinear interpolation functions
- Bilinear Interpolation function created:
- Input: float xCoord, float yCoord, float[,] values
- Linear Interpolation function created:
- Input : float coord, float valCoordDown, float valCoordUp
- This requires a bit more work from the caller (identifying the values for the rounded down and up coord) however it also means it can be called by the Bilinear Interpolation function as required. This requirement wasn’t needed in the final version however it is remaining this way in order for other elements to be able to call it from a 2D context (as opposed to only requiring a 1D array)
3 hours (41 hours running total)
A nice quick one tonight; the mental redevelopment of the viewshed implementation led me to the (rather obvious) realisation that I should approach it the way you are taught to approach programming problems from pretty much day 1… Break it down into discrete bits. As a result I have decided to create static helper functions that handle interpolation for me. The Bilinear function can be passed a non integer coordinate and the 2D array of values and will handle all the calculations. This means not only will the code that requires this be MUCH cleaner, it will save on code duplication (eg. if interpolation is required when checking FUP width at a set orientation etc).
Almost more importantly than the above, it means I can test this part of the logic in isolation. It would be very difficult to effectively test the viewshed as a whole (and identify the source of bugs if they were found!) however now I can be confident that the interpolation calculations are correct. This was easy to test in isolation using random data and confirming the data using my own calculations supported by the online calculator at http://www.ajdesigner.com/phpinterpolation/bilinear_interpolation_equation.php
This is a good result as it isolates one of the more complex elements of the viewshed calculation. Now I can focus on the logic inside the viewshed algorithm without worrying about more intricate maths.