Drawing a Topographical Map

前端 未结 9 2326
遥遥无期
遥遥无期 2020-12-22 21:31

I\'ve been working on a visualization project for 2-dimensional continuous data. It\'s the kind of thing you could use to study elevation data or temperature patterns on a 2

9条回答
  •  被撕碎了的回忆
    2020-12-22 21:54

    In response to your comment to @erickson and to answer the point about calculating the gradient of your function. Instead of calculating the derivatives of your 300 term function you could do a numeric differentiation as follows.

    Given a point [x,y] in your image you could calculate the gradient (direction of steepest decent)

    g={  ( f(x+dx,y)-f(x-dx,y) )/(2*dx), 
      {  ( f(x,y+dy)-f(x,y-dy) )/(2*dy) 
    

    where dx and dy could be the spacing in your grid. The contour line will run perpendicular to the gradient. So, to get the contour direction, c, we can multiply g=[v,w] by matrix, A=[0 -1, 1 0] giving

    c = [-w,v]
    

提交回复
热议问题