[Manifold-l] Need some help with lines and slopes
Dimitri Rotow
dar at manifold.net
Tue Oct 3 18:41:38 CDT 2006
> I have a map with two drawings, a surface where I can run my
> mouse cursor over and it will report a z-value, and an empty
> drawing. I would like to draw a segmented line on the empty
> drawing layer and get back the length and slope of the line
> based on the underlying z-values. I can seem to figure out
> if this is a spatial or topology overlay problem. The
> transfer heights transform only returns the height (sum,
> average, ... ) of the centroid of the line. Any suggestions
> on how to approach this problem would be appreciated.
You'll have to script either of these. The two tasks are related as they
are both riffs on computing elementary values of a right triangle.
First, though, let's consider the "slope" of the line. A line traversing an
irregular surface will have no single slope value. Consider, for example, a
road that goes up a hill and then down a hill. There's no one "slope" to
that road. There may be a slope for any one straight line segment, and you
might compute an "average" slope by an arithmetic aggregation of slopes for
individual line segments that comprise the polyline, but if you want to
attach just one "slope" number to the line you are going to have to decide
what sort of approximation or aggregation you want that number to be.
To get the 3D length of a line you first decompose it into individual line
segments. You know the height of both ends of each segment, so you know the
difference in height between the segments. You know the length of the line
segment. Using the Pythagorean formula you can find the length of the
hypoteneuse given the length of the base of a right-angle triangle (the
length of the line segment) and the height of the triangle (the difference
in z of the end points). Add the hypoteneuse lengths of all the line
segments for the line to get the length of the line.
You could use a similar process to compute the slope of each segment. You
know the length of the segment and the difference in heights and even (from
the above) the length of the hypotenuse. It's therefore a simple
calculation to get the value of the acute angle between the base and the
hypoteneuse. Once you have the slope for each line segment you can decide
how you want to aggregate them to get some sort of average or combined slope
for the line.
You could simplify the script by doing some manual work. For example,
create points at each coordinate of a line and then transfer heights from
the surface to each point. This and suitable "flag" attributes used wisely
will simplify the scripts.
Cheers,
Dimitri
More information about the Manifold-l
mailing list