source: grass/trunk/raster/r.param.scale/feature.c

Last change on this file was 68015, checked in by neteler, 8 years ago

various spelling errors fixed

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id
  • Property svn:mime-type set to text/x-csrc
File size: 3.0 KB
Line 
1/* changes line 37 for Linux - Markus Neteler (Jan. 1998) */
2
3/*****************************************************************************/
4
5/*** ***/
6
7/*** feature() ***/
8
9/*** Returns a terrain feature based on the 6 quadratic coefficients ***/
10
11/*** that define a local trend surface. ***/
12
13/*** Jo Wood, Department of Geography, V2.1 30th March, 1995 ***/
14
15/*** ***/
16
17/*****************************************************************************/
18
19#include "param.h"
20#include <math.h>
21
22
23DCELL feature(double *coeff)
24{ /* Set of six quadratic coefficients. */
25
26 /* Quadratic function in the form of
27
28 z = ax^2 + by^2 + cxy + dx + ey +f */
29
30 double a = C_A * zscale, /* Scale parameters if necessary. */
31 b = C_B * zscale,
32 c = C_C * zscale, d = C_D * zscale, e = C_E * zscale;
33
34 double maxic, minic, /* Minimium and maximum curvature. */
35 slope, /* Slope. */
36 crosc; /* Cross-sectional curvature. */
37
38 minic = (-a - b - sqrt((a - b) * (a - b) + c * c));
39 maxic = (-a - b + sqrt((a - b) * (a - b) + c * c));
40 slope = RAD2DEG * atan(sqrt((d * d) + (e * e)));
41 crosc = -2.0 * (b * d * d + a * e * e - c * d * e) / (d * d + e * e);
42
43
44 /*
45 Feature slope crosc maxic minic
46
47 Peak 0 # +ve +ve
48 Ridge 0 # +ve 0
49 +ve +ve # #
50 Pass 0 # +ve -ve
51 Plane 0 # 0 0
52 +ve 0 # #
53 Channel 0 # 0 -ve
54 +ve -ve # #
55 Pit 0 # -ve -ve
56
57 Table 5.3 Simplified feature classification criteria.
58 # indicates undefined, or not part of selection criteria.
59 http://www.geog.le.ac.uk/jwo/research/dem_char/thesis/05feat.htm
60 */
61
62 /* Case 1: Surface is sloping. Cannot be a peak,pass or pit. Therefore
63 calculate the cross-sectional curvature to characterise as
64 channel, ridge or planar. */
65
66 if (slope > slope_tol) {
67 if (crosc > curve_tol) {
68 return (RIDGE);
69 }
70 else if (crosc < -curve_tol) {
71 return (CHANNEL);
72 }
73 else {
74 return (FLAT);
75 }
76 }
77 else {
78
79
80 /* Case 2: Surface has (approximately) vertical slope normal. Feature
81 can be of any type. */
82
83 if (maxic > curve_tol) {
84 if (minic > curve_tol) {
85 return (PEAK);
86 }
87 else if (minic < -curve_tol) {
88 return (PASS);
89 }
90 else {
91 return (RIDGE);
92 }
93 }
94 else if (maxic < -curve_tol) {
95 if (minic < -curve_tol) {
96 return (PIT);
97 }
98 }
99 else {
100 if (minic < -curve_tol) {
101 return (CHANNEL);
102 }
103 else if (minic > curve_tol && minic < -curve_tol) {
104 return (FLAT);
105 }
106 }
107 }
108 return (FLAT);
109}
Note: See TracBrowser for help on using the repository browser.