Skip to content

Commit

Permalink
updates due to negative z_factors
Browse files Browse the repository at this point in the history
  • Loading branch information
jblindsay committed Dec 12, 2022
1 parent 5a54e68 commit 138d55d
Show file tree
Hide file tree
Showing 19 changed files with 53 additions and 53 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file added whitebox-lidar/.DS_Store
Binary file not shown.
Binary file modified whitebox-plugins/.DS_Store
Binary file not shown.
Binary file added whitebox-raster/.DS_Store
Binary file not shown.
Binary file modified whitebox-runner/.DS_Store
Binary file not shown.
Binary file modified whitebox-tools-app/.DS_Store
Binary file not shown.
10 changes: 5 additions & 5 deletions whitebox-tools-app/src/tools/terrain_analysis/aspect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ impl WhiteboxTool for Aspect {

let mut input_file = String::new();
let mut output_file = String::new();
let mut z_factor = -1f64;
let mut z_factor = 1f64;

if args.len() == 0 {
return Err(Error::new(
Expand Down Expand Up @@ -277,11 +277,11 @@ impl WhiteboxTool for Aspect {
of Digital Terrain Modelling, Chapter 4, pg. 117. I can't figure out why, but this
only works if you change the sign of q below.
*/
p = -1. / (420. * res) * (44. * (z[3] + z[23] - z[1] - z[21]) + 31. * (z[0] + z[20] - z[4] - z[24]
p = 1. / (420. * res) * (44. * (z[3] + z[23] - z[1] - z[21]) + 31. * (z[0] + z[20] - z[4] - z[24]
+ 2. * (z[8] + z[18] - z[6] - z[16])) + 17. * (z[14] - z[10] + 4. * (z[13] - z[11]))
+ 5. * (z[9] + z[19] - z[5] - z[15]));

q = -1. / (420. * res) * (44. * (z[5] + z[9] - z[15] - z[19]) + 31. * (z[20] + z[24] - z[0] - z[4]
q = 1. / (420. * res) * (44. * (z[5] + z[9] - z[15] - z[19]) + 31. * (z[20] + z[24] - z[0] - z[4]
+ 2. * (z[6] + z[8] - z[16] - z[18])) + 17. * (z[2] - z[22] + 4. * (z[7] - z[17]))
+ 5. * (z[1] + z[3] - z[21] - z[23]));

Expand Down Expand Up @@ -409,10 +409,10 @@ impl WhiteboxTool for Aspect {
of Digital Terrain Modelling, Chapter 4, pg. 117.
*/

p = -((a * a * c * d * (d + e) * (z[2] - z[0]) + b * (a * a * d * d + c * c * e * e) * (z[5] - z[3]) + a * c * c * e * (d + e) * (z[8] - z[6]))
p = ((a * a * c * d * (d + e) * (z[2] - z[0]) + b * (a * a * d * d + c * c * e * e) * (z[5] - z[3]) + a * c * c * e * (d + e) * (z[8] - z[6]))
/ (2. * (a * a * c * c * (d + e).powi(2) + b * b * (a * a * d * d + c * c * e * e))));

q = -(1. / (3. * d * e * (d + e) * (a.powi(4) + b.powi(4) + c.powi(4)))
q = (1. / (3. * d * e * (d + e) * (a.powi(4) + b.powi(4) + c.powi(4)))
* ((d * d * (a.powi(4) + b.powi(4) + b * b * c * c) + c * c * e * e * (a * a - b * b)) * (z[0] + z[2])
- (d * d * (a.powi(4) + c.powi(4) + b * b * c * c) - e * e * (a.powi(4) + c.powi(4) + a * a * b * b)) * (z[3] + z[5])
- (e * e * (b.powi(4) + c.powi(4) + a * a * b * b) - a * a * d * d * (b * b - c * c)) * (z[6] + z[8])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,11 +339,11 @@ impl WhiteboxTool for GaussianCurvature {
s = 1. / (100. * res * res) * (z[8] + z[16] - z[6] - z[18] + 4. * (z[4] + z[20] - z[0] - z[24])
+ 2. * (z[3] + z[9] + z[15] + z[21] - z[1] - z[5] - z[19] - z[23]));

p = -1. / (420. * res) * (44. * (z[3] + z[23] - z[1] - z[21]) + 31. * (z[0] + z[20] - z[4] - z[24]
p = 1. / (420. * res) * (44. * (z[3] + z[23] - z[1] - z[21]) + 31. * (z[0] + z[20] - z[4] - z[24]
+ 2. * (z[8] + z[18] - z[6] - z[16])) + 17. * (z[14] - z[10] + 4. * (z[13] - z[11]))
+ 5. * (z[9] + z[19] - z[5] - z[15]));

q = -1. / (420. * res) * (44. * (z[5] + z[9] - z[15] - z[19]) + 31. * (z[20] + z[24] - z[0] - z[4]
q = 1. / (420. * res) * (44. * (z[5] + z[9] - z[15] - z[19]) + 31. * (z[20] + z[24] - z[0] - z[4]
+ 2. * (z[6] + z[8] - z[16] - z[18])) + 17. * (z[2] - z[22] + 4. * (z[7] - z[17]))
+ 5. * (z[1] + z[3] - z[21] - z[23]));

Expand Down Expand Up @@ -505,10 +505,10 @@ impl WhiteboxTool for GaussianCurvature {
s = (c * (a * a * (d + e) + b * b * e) * (z[2] - z[0]) - b * (a * a * d - c * c * e) * (z[3] - z[5]) + a * (c * c * (d + e) + b * b * d) * (z[6] - z[8]))
/ (2. * (a * a * c * c * (d + e).powi(2) + b * b * (a * a * d * d + c * c * e * e)));

p = -((a * a * c * d * (d + e) * (z[2] - z[0]) + b * (a * a * d * d + c * c * e * e) * (z[5] - z[3]) + a * c * c * e * (d + e) * (z[8] - z[6]))
p = ((a * a * c * d * (d + e) * (z[2] - z[0]) + b * (a * a * d * d + c * c * e * e) * (z[5] - z[3]) + a * c * c * e * (d + e) * (z[8] - z[6]))
/ (2. * (a * a * c * c * (d + e).powi(2) + b * b * (a * a * d * d + c * c * e * e))));

q = -(1. / (3. * d * e * (d + e) * (a.powi(4) + b.powi(4) + c.powi(4)))
q = (1. / (3. * d * e * (d + e) * (a.powi(4) + b.powi(4) + c.powi(4)))
* ((d * d * (a.powi(4) + b.powi(4) + b * b * c * c) + c * c * e * e * (a * a - b * b)) * (z[0] + z[2])
- (d * d * (a.powi(4) + c.powi(4) + b * b * c * c) - e * e * (a.powi(4) + c.powi(4) + a * a * b * b)) * (z[3] + z[5])
- (e * e * (b.powi(4) + c.powi(4) + a * a * b * b) - a * a * d * d * (b * b - c * c)) * (z[6] + z[8])
Expand Down
10 changes: 5 additions & 5 deletions whitebox-tools-app/src/tools/terrain_analysis/hillshade.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ impl WhiteboxTool for Hillshade {
let mut output_file = String::new();
let mut azimuth = 315.0f64;
let mut altitude = 30.0f64;
let mut z_factor = -1f64;
let mut z_factor = 1f64;

if args.len() == 0 {
return Err(Error::new(
Expand Down Expand Up @@ -348,11 +348,11 @@ impl WhiteboxTool for Hillshade {
The following equations have been taken from Florinsky (2016) Principles and Methods
of Digital Terrain Modelling, Chapter 4, pg. 117.
*/
p = -1. / (420. * res) * (44. * (z[3] + z[23] - z[1] - z[21]) + 31. * (z[0] + z[20] - z[4] - z[24]
p = 1. / (420. * res) * (44. * (z[3] + z[23] - z[1] - z[21]) + 31. * (z[0] + z[20] - z[4] - z[24]
+ 2. * (z[8] + z[18] - z[6] - z[16])) + 17. * (z[14] - z[10] + 4. * (z[13] - z[11]))
+ 5. * (z[9] + z[19] - z[5] - z[15]));

q = -1. / (420. * res) * (44. * (z[5] + z[9] - z[15] - z[19]) + 31. * (z[20] + z[24] - z[0] - z[4]
q = 1. / (420. * res) * (44. * (z[5] + z[9] - z[15] - z[19]) + 31. * (z[20] + z[24] - z[0] - z[4]
+ 2. * (z[6] + z[8] - z[16] - z[18])) + 17. * (z[2] - z[22] + 4. * (z[7] - z[17]))
+ 5. * (z[1] + z[3] - z[21] - z[23]));

Expand Down Expand Up @@ -498,10 +498,10 @@ impl WhiteboxTool for Hillshade {
of Digital Terrain Modelling, Chapter 4, pg. 117.
*/

p = -((a * a * c * d * (d + e) * (z[2] - z[0]) + b * (a * a * d * d + c * c * e * e) * (z[5] - z[3]) + a * c * c * e * (d + e) * (z[8] - z[6]))
p = ((a * a * c * d * (d + e) * (z[2] - z[0]) + b * (a * a * d * d + c * c * e * e) * (z[5] - z[3]) + a * c * c * e * (d + e) * (z[8] - z[6]))
/ (2. * (a * a * c * c * (d + e).powi(2) + b * b * (a * a * d * d + c * c * e * e))));

q = -(1. / (3. * d * e * (d + e) * (a.powi(4) + b.powi(4) + c.powi(4)))
q = (1. / (3. * d * e * (d + e) * (a.powi(4) + b.powi(4) + c.powi(4)))
* ((d * d * (a.powi(4) + b.powi(4) + b * b * c * c) + c * c * e * e * (a * a - b * b)) * (z[0] + z[2])
- (d * d * (a.powi(4) + c.powi(4) + b * b * c * c) - e * e * (a.powi(4) + c.powi(4) + a * a * b * b)) * (z[3] + z[5])
- (e * e * (b.powi(4) + c.powi(4) + a * a * b * b) - a * a * d * d * (b * b - c * c)) * (z[6] + z[8])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,11 @@ impl WhiteboxTool for MaximalCurvature {
s = 1. / (100. * res * res) * (z[8] + z[16] - z[6] - z[18] + 4. * (z[4] + z[20] - z[0] - z[24])
+ 2. * (z[3] + z[9] + z[15] + z[21] - z[1] - z[5] - z[19] - z[23]));

p = -1. / (420. * res) * (44. * (z[3] + z[23] - z[1] - z[21]) + 31. * (z[0] + z[20] - z[4] - z[24]
p = 1. / (420. * res) * (44. * (z[3] + z[23] - z[1] - z[21]) + 31. * (z[0] + z[20] - z[4] - z[24]
+ 2. * (z[8] + z[18] - z[6] - z[16])) + 17. * (z[14] - z[10] + 4. * (z[13] - z[11]))
+ 5. * (z[9] + z[19] - z[5] - z[15]));

q = -1. / (420. * res) * (44. * (z[5] + z[9] - z[15] - z[19]) + 31. * (z[20] + z[24] - z[0] - z[4]
q = 1. / (420. * res) * (44. * (z[5] + z[9] - z[15] - z[19]) + 31. * (z[20] + z[24] - z[0] - z[4]
+ 2. * (z[6] + z[8] - z[16] - z[18])) + 17. * (z[2] - z[22] + 4. * (z[7] - z[17]))
+ 5. * (z[1] + z[3] - z[21] - z[23]));

Expand Down Expand Up @@ -511,10 +511,10 @@ impl WhiteboxTool for MaximalCurvature {
s = (c * (a * a * (d + e) + b * b * e) * (z[2] - z[0]) - b * (a * a * d - c * c * e) * (z[3] - z[5]) + a * (c * c * (d + e) + b * b * d) * (z[6] - z[8]))
/ (2. * (a * a * c * c * (d + e).powi(2) + b * b * (a * a * d * d + c * c * e * e)));

p = -((a * a * c * d * (d + e) * (z[2] - z[0]) + b * (a * a * d * d + c * c * e * e) * (z[5] - z[3]) + a * c * c * e * (d + e) * (z[8] - z[6]))
p = ((a * a * c * d * (d + e) * (z[2] - z[0]) + b * (a * a * d * d + c * c * e * e) * (z[5] - z[3]) + a * c * c * e * (d + e) * (z[8] - z[6]))
/ (2. * (a * a * c * c * (d + e).powi(2) + b * b * (a * a * d * d + c * c * e * e))));

q = -(1. / (3. * d * e * (d + e) * (a.powi(4) + b.powi(4) + c.powi(4)))
q = (1. / (3. * d * e * (d + e) * (a.powi(4) + b.powi(4) + c.powi(4)))
* ((d * d * (a.powi(4) + b.powi(4) + b * b * c * c) + c * c * e * e * (a * a - b * b)) * (z[0] + z[2])
- (d * d * (a.powi(4) + c.powi(4) + b * b * c * c) - e * e * (a.powi(4) + c.powi(4) + a * a * b * b)) * (z[3] + z[5])
- (e * e * (b.powi(4) + c.powi(4) + a * a * b * b) - a * a * d * d * (b * b - c * c)) * (z[6] + z[8])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@ impl WhiteboxTool for MeanCurvature {
s = 1. / (100. * res * res) * (z[8] + z[16] - z[6] - z[18] + 4. * (z[4] + z[20] - z[0] - z[24])
+ 2. * (z[3] + z[9] + z[15] + z[21] - z[1] - z[5] - z[19] - z[23]));

p = -1. / (420. * res) * (44. * (z[3] + z[23] - z[1] - z[21]) + 31. * (z[0] + z[20] - z[4] - z[24]
p = 1. / (420. * res) * (44. * (z[3] + z[23] - z[1] - z[21]) + 31. * (z[0] + z[20] - z[4] - z[24]
+ 2. * (z[8] + z[18] - z[6] - z[16])) + 17. * (z[14] - z[10] + 4. * (z[13] - z[11]))
+ 5. * (z[9] + z[19] - z[5] - z[15]));

q = -1. / (420. * res) * (44. * (z[5] + z[9] - z[15] - z[19]) + 31. * (z[20] + z[24] - z[0] - z[4]
q = 1. / (420. * res) * (44. * (z[5] + z[9] - z[15] - z[19]) + 31. * (z[20] + z[24] - z[0] - z[4]
+ 2. * (z[6] + z[8] - z[16] - z[18])) + 17. * (z[2] - z[22] + 4. * (z[7] - z[17]))
+ 5. * (z[1] + z[3] - z[21] - z[23]));

Expand Down Expand Up @@ -507,10 +507,10 @@ impl WhiteboxTool for MeanCurvature {
s = (c * (a * a * (d + e) + b * b * e) * (z[2] - z[0]) - b * (a * a * d - c * c * e) * (z[3] - z[5]) + a * (c * c * (d + e) + b * b * d) * (z[6] - z[8]))
/ (2. * (a * a * c * c * (d + e).powi(2) + b * b * (a * a * d * d + c * c * e * e)));

p = -((a * a * c * d * (d + e) * (z[2] - z[0]) + b * (a * a * d * d + c * c * e * e) * (z[5] - z[3]) + a * c * c * e * (d + e) * (z[8] - z[6]))
p = ((a * a * c * d * (d + e) * (z[2] - z[0]) + b * (a * a * d * d + c * c * e * e) * (z[5] - z[3]) + a * c * c * e * (d + e) * (z[8] - z[6]))
/ (2. * (a * a * c * c * (d + e).powi(2) + b * b * (a * a * d * d + c * c * e * e))));

q = -(1. / (3. * d * e * (d + e) * (a.powi(4) + b.powi(4) + c.powi(4)))
q = (1. / (3. * d * e * (d + e) * (a.powi(4) + b.powi(4) + c.powi(4)))
* ((d * d * (a.powi(4) + b.powi(4) + b * b * c * c) + c * c * e * e * (a * a - b * b)) * (z[0] + z[2])
- (d * d * (a.powi(4) + c.powi(4) + b * b * c * c) - e * e * (a.powi(4) + c.powi(4) + a * a * b * b)) * (z[3] + z[5])
- (e * e * (b.powi(4) + c.powi(4) + a * a * b * b) - a * a * d * d * (b * b - c * c)) * (z[6] + z[8])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@ impl WhiteboxTool for MinimalCurvature {
s = 1. / (100. * res * res) * (z[8] + z[16] - z[6] - z[18] + 4. * (z[4] + z[20] - z[0] - z[24])
+ 2. * (z[3] + z[9] + z[15] + z[21] - z[1] - z[5] - z[19] - z[23]));

p = -1. / (420. * res) * (44. * (z[3] + z[23] - z[1] - z[21]) + 31. * (z[0] + z[20] - z[4] - z[24]
p = 1. / (420. * res) * (44. * (z[3] + z[23] - z[1] - z[21]) + 31. * (z[0] + z[20] - z[4] - z[24]
+ 2. * (z[8] + z[18] - z[6] - z[16])) + 17. * (z[14] - z[10] + 4. * (z[13] - z[11]))
+ 5. * (z[9] + z[19] - z[5] - z[15]));

q = -1. / (420. * res) * (44. * (z[5] + z[9] - z[15] - z[19]) + 31. * (z[20] + z[24] - z[0] - z[4]
q = 1. / (420. * res) * (44. * (z[5] + z[9] - z[15] - z[19]) + 31. * (z[20] + z[24] - z[0] - z[4]
+ 2. * (z[6] + z[8] - z[16] - z[18])) + 17. * (z[2] - z[22] + 4. * (z[7] - z[17]))
+ 5. * (z[1] + z[3] - z[21] - z[23]));

Expand Down Expand Up @@ -512,10 +512,10 @@ impl WhiteboxTool for MinimalCurvature {
s = (c * (a * a * (d + e) + b * b * e) * (z[2] - z[0]) - b * (a * a * d - c * c * e) * (z[3] - z[5]) + a * (c * c * (d + e) + b * b * d) * (z[6] - z[8]))
/ (2. * (a * a * c * c * (d + e).powi(2) + b * b * (a * a * d * d + c * c * e * e)));

p = -((a * a * c * d * (d + e) * (z[2] - z[0]) + b * (a * a * d * d + c * c * e * e) * (z[5] - z[3]) + a * c * c * e * (d + e) * (z[8] - z[6]))
p = ((a * a * c * d * (d + e) * (z[2] - z[0]) + b * (a * a * d * d + c * c * e * e) * (z[5] - z[3]) + a * c * c * e * (d + e) * (z[8] - z[6]))
/ (2. * (a * a * c * c * (d + e).powi(2) + b * b * (a * a * d * d + c * c * e * e))));

q = -(1. / (3. * d * e * (d + e) * (a.powi(4) + b.powi(4) + c.powi(4)))
q = (1. / (3. * d * e * (d + e) * (a.powi(4) + b.powi(4) + c.powi(4)))
* ((d * d * (a.powi(4) + b.powi(4) + b * b * c * c) + c * c * e * e * (a * a - b * b)) * (z[0] + z[2])
- (d * d * (a.powi(4) + c.powi(4) + b * b * c * c) - e * e * (a.powi(4) + c.powi(4) + a * a * b * b)) * (z[3] + z[5])
- (e * e * (b.powi(4) + c.powi(4) + a * a * b * b) - a * a * d * d * (b * b - c * c)) * (z[6] + z[8])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ impl WhiteboxTool for MultidirectionalHillshade {
let mut input_file = String::new();
let mut output_file = String::new();
let mut altitude = 30.0f64;
let mut z_factor = -1f64;
let mut z_factor = 1f64;
let mut multidirection360mode = false;

if args.len() == 0 {
Expand Down Expand Up @@ -476,11 +476,11 @@ impl WhiteboxTool for MultidirectionalHillshade {
The following equations have been taken from Florinsky (2016) Principles and Methods
of Digital Terrain Modelling, Chapter 4, pg. 117.
*/
p = -1. / (420. * res) * (44. * (z[3] + z[23] - z[1] - z[21]) + 31. * (z[0] + z[20] - z[4] - z[24]
p = 1. / (420. * res) * (44. * (z[3] + z[23] - z[1] - z[21]) + 31. * (z[0] + z[20] - z[4] - z[24]
+ 2. * (z[8] + z[18] - z[6] - z[16])) + 17. * (z[14] - z[10] + 4. * (z[13] - z[11]))
+ 5. * (z[9] + z[19] - z[5] - z[15]));

q = -1. / (420. * res) * (44. * (z[5] + z[9] - z[15] - z[19]) + 31. * (z[20] + z[24] - z[0] - z[4]
q = 1. / (420. * res) * (44. * (z[5] + z[9] - z[15] - z[19]) + 31. * (z[20] + z[24] - z[0] - z[4]
+ 2. * (z[6] + z[8] - z[16] - z[18])) + 17. * (z[2] - z[22] + 4. * (z[7] - z[17]))
+ 5. * (z[1] + z[3] - z[21] - z[23]));

Expand Down Expand Up @@ -656,10 +656,10 @@ impl WhiteboxTool for MultidirectionalHillshade {
of Digital Terrain Modelling, Chapter 4, pg. 117.
*/

p = -((a * a * c * d * (d + e) * (z[2] - z[0]) + b * (a * a * d * d + c * c * e * e) * (z[5] - z[3]) + a * c * c * e * (d + e) * (z[8] - z[6]))
p = ((a * a * c * d * (d + e) * (z[2] - z[0]) + b * (a * a * d * d + c * c * e * e) * (z[5] - z[3]) + a * c * c * e * (d + e) * (z[8] - z[6]))
/ (2. * (a * a * c * c * (d + e).powi(2) + b * b * (a * a * d * d + c * c * e * e))));

q = -(1. / (3. * d * e * (d + e) * (a.powi(4) + b.powi(4) + c.powi(4)))
q = (1. / (3. * d * e * (d + e) * (a.powi(4) + b.powi(4) + c.powi(4)))
* ((d * d * (a.powi(4) + b.powi(4) + b * b * c * c) + c * c * e * e * (a * a - b * b)) * (z[0] + z[2])
- (d * d * (a.powi(4) + c.powi(4) + b * b * c * c) - e * e * (a.powi(4) + c.powi(4) + a * a * b * b)) * (z[3] + z[5])
- (e * e * (b.powi(4) + c.powi(4) + a * a * b * b) - a * a * d * d * (b * b - c * c)) * (z[6] + z[8])
Expand Down
Loading

0 comments on commit 138d55d

Please sign in to comment.