Re: [Algorithms] Tangential Curvature of terrain
Brought to you by:
vexxed72
From: Thatcher U. <tu...@tu...> - 2000-08-21 07:34:53
|
> I'd like to enhance my texture synthesizer for terrain. In particular, I'd > like to make my ecosystem-classification depend on the tangential curvature > of the terrain. I guess that may require some explanation. > > I have a set of ecosystem definititions. Such definitions include things > like: > [1] the upper elevation limit at which the ecosystem can exist > [2] the minimum and maximum slops at which the ecosystem can exist > [3] elevation skewing > [4] etc... > > Now, for each data point in the height field, I go through the set of > ecosystems, and determine which ecosystem exists at this data point. Such a > system is very useful for 'realistic' texture synthesis, and it's also great > to create a natural distribution of trees. > However, there's one thing I haven't been able to implement, yet. I'd like > to make my ecosystem classification depend on the concavity/convexity of the > terrain. I know that this requires me to compute the tangential curvature of > the terrain (which is usually stored in an extra curvature field). > > To make it easier for you to understand, you can have a loot at the > following web-site: > http://www2.gis.uiuc.edu:2280/modviz/ > > The fifth terrain image (from above) shows the tangential curvature of some > terrain. This is exactly what I'd like to do. I know how I need to use the > information from curvature field to modify my ecosystem classification, but > I have no idea how I to compute the tangential curvature field itself. In Ah. I think I understand. Basically, the curvature of a function is its second derivative. The first derivative is the slope. But for a 2D function like a heightfield, these derivatives are vectors, not scalars. This makes sense intuitively by noticing that a heightfield can be convex in one direction and concave in another direction.You're interested in scalar values I think, which means you want the curvature of the heightfield with respect to a certain direction. In the web page you gave, they compute profile curvature and tangential curvature, which are the curvatures of the terrain in two orthogonal directions. The profile curvature is the curvature along the "fall-line": i.e. the direction of maximum slope. You can find the fall-line with something like: fall_line = | up_axis x (normal x up_axis) | That gives you a vector in the plane tangent to the surface, pointing down the hill (Those 'x's are cross-products.) When the normal is vertical, the fall-line is undefined (there's no downhill direction). To estimate the curvature, you measure the difference between the actual slope near the point, and the fall-line. So something like (assuming +y is up): samp = fall_line * delta; profile_curvature = ((terrainheight(p + samp) - (p.y + samp.y)) + (terrainheight(p - samp) - (p.y - samp.y))) / delta; Delta is some "small" distance; it probably makes sense for it to be equal to your heightfield sample spacing. Basically you're measuring the difference between the straight fall-line and what the terrain actually does; if the terrain is concave, the actual terrain samples are higher than the fall-line and the formula comes out positive; if the terrain is convex then the samples are lower than the fall line and the formula comes out negative. The "tangent curvature" is the same thing, except instead of using the fall-line, you use a vector that's perpendicular to the fall-line, and parallel to the terrain surface, i.e. a vector that points across the slope of the terrain. It's easy to compute this tangent vector, it's just (normal x fall_line). Or the negative of that; it doesn't matter. Replace "fall-line" with the tangent vector, and you'll get the tangent curvature you're looking for. Apologies if I abused some calculus concepts or got some scale factors off. But that's the basic idea. Hope this helps, -- Thatcher Ulrich http://tulrich.com |