0

I have an elevation map of a mountainous area (large 2d array with z values)

I want to know the height of the apparent horizon angle for all compass bearings for certain points on my height map.

To illustrate, this website has some examples of what I want.

Edit: I've stopped trying to find a function that does this and am now writing my own.

My approach is drawing lines from my point radially, interpolating the height along those lines and then taking max(z/r) along each line.

If you know a function that already does this, please tell me, if not, hopefully I'll be able to upload one soon.

Swier
  • 4,047
  • 3
  • 28
  • 52
  • 2
    Why `matlab`? Have you already written some `matlab` code to solve your problem? Would you please show us what you've done so far? – gboffi Apr 17 '15 at 09:18
  • 1
    So far I've looked through lots of documentation, not found anything and I was hoping someone here knew the right tool. At the moment I'm working on using this: http://www.mathworks.com/matlabcentral/fileexchange/49065-shadem and then iterating over all possible angles (360*90) to find out when my points are shaded and when they aren't. But there's got to be a better way of doing this. Why matlab: it's part of a bigger physical model written in matlab, and I need to incorporate terrain shading to calculate energy flux through the surface – Swier Apr 17 '15 at 09:28
  • @Swier: It seems you haven't really thought about the mathematical background. I suggest you try to solve it for 0° first. First calculate at which angle each pixel on the line appears (trigonometric function), then take the maximum. – Daniel Apr 17 '15 at 09:56

1 Answers1

2

Let's say that you have 3 matrices, X Y and Z and your position (x,y,z), you can compute

R = sqrt((X-x)**2 + (Y-y)**2) (tx Daniel...)

R = sqrt((X-x).^2 + (Y-y).^2)
Z = (Z-z)

i.e., the distances from the position and the relative heights, so that

T = Z/R

is a matrix of tangents, that are a monotonous function of the visual angle from the position to the surrounding terrain.

For a given direction you can find the list of points closest on the grid with a variation of the Bresenham algorithm and finally find the highest T value on your list of points.

Eventually, from the list of max T (tangents) values for different directions you can compute the visual angles from your position.

gboffi
  • 22,939
  • 8
  • 54
  • 85