height_map_examples.cc
Go to the documentation of this file.
1 /******************************************************************************
2 Copyright (c) 2018, Alexander W. Winkler. All rights reserved.
3 
4 Redistribution and use in source and binary forms, with or without
5 modification, are permitted provided that the following conditions are met:
6 
7 * Redistributions of source code must retain the above copyright notice, this
8  list of conditions and the following disclaimer.
9 
10 * Redistributions in binary form must reproduce the above copyright notice,
11  this list of conditions and the following disclaimer in the documentation
12  and/or other materials provided with the distribution.
13 
14 * Neither the name of the copyright holder nor the names of its
15  contributors may be used to endorse or promote products derived from
16  this software without specific prior written permission.
17 
18 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 ******************************************************************************/
29 
31 
32 namespace towr {
33 
34 
35 FlatGround::FlatGround(double height)
36 {
37  height_ = height;
38 }
39 
40 double
41 Block::GetHeight (double x, double y) const
42 {
43  double h = 0.0;
44 
45  // very steep ramp leading up to block
46  if (block_start <= x && x <=block_start+eps_)
47  h = slope_*(x-block_start);
48 
49  if (block_start+eps_ <= x && x <= block_start+length_)
50  h = height_;
51 
52  return h;
53 }
54 
55 double
56 Block::GetHeightDerivWrtX (double x, double y) const
57 {
58  double dhdx = 0.0;
59 
60  // very steep ramp leading up to block
61  if (block_start <= x && x <=block_start+eps_)
62  dhdx = slope_;
63 
64  return dhdx;
65 }
66 
67 
68 // STAIRS
69 double
70 Stairs::GetHeight (double x, double y) const
71 {
72  double h = 0.0;
73 
74  if (x>=first_step_start_)
75  h = height_first_step;
76 
77  if (x>=first_step_start_+first_step_width_)
78  h = height_second_step;
79 
80  if (x>=first_step_start_+first_step_width_+width_top)
81  h = 0.0;
82 
83  return h;
84 }
85 
86 
87 // GAP
88 double
89 Gap::GetHeight (double x, double y) const
90 {
91  double h = 0.0;
92 
93  // modelled as parabola
94  if (gap_start_ <= x && x <= gap_end_x)
95  h = a*x*x + b*x + c;
96 
97  return h;
98 }
99 
100 double
101 Gap::GetHeightDerivWrtX (double x, double y) const
102 {
103  double dhdx = 0.0;
104 
105  if (gap_start_ <= x && x <= gap_end_x)
106  dhdx = 2*a*x + b;
107 
108  return dhdx;
109 }
110 
111 double
112 Gap::GetHeightDerivWrtXX (double x, double y) const
113 {
114  double dzdxx = 0.0;
115 
116  if (gap_start_ <= x && x <= gap_end_x)
117  dzdxx = 2*a;
118 
119  return dzdxx;
120 }
121 
122 
123 // SLOPE
124 double
125 Slope::GetHeight (double x, double y) const
126 {
127  double z = 0.0;
128  if (x >= slope_start_)
129  z = slope_*(x-slope_start_);
130 
131  // going back down
132  if (x >= x_down_start_) {
133  z = height_center - slope_*(x-x_down_start_);
134  }
135 
136  // back on flat ground
137  if (x >= x_flat_start_)
138  z = 0.0;
139 
140  return z;
141 }
142 
143 double
144 Slope::GetHeightDerivWrtX (double x, double y) const
145 {
146  double dzdx = 0.0;
147  if (x >= slope_start_)
148  dzdx = slope_;
149 
150  if (x >= x_down_start_)
151  dzdx = -slope_;
152 
153  if (x >= x_flat_start_)
154  dzdx = 0.0;
155 
156  return dzdx;
157 }
158 
159 
160 // Chimney
161 double
162 Chimney::GetHeight (double x, double y) const
163 {
164  double z = 0.0;
165 
166  if (x_start_<=x && x<=x_end_)
167  z = slope_*(y-y_start_);
168 
169  return z;
170 }
171 
172 double
173 Chimney::GetHeightDerivWrtY (double x, double y) const
174 {
175  double dzdy = 0.0;
176 
177  if (x_start_<= x && x<= x_end_)
178  dzdy = slope_;
179 
180  return dzdy;
181 }
182 
183 
184 // Chimney LR
185 double
186 ChimneyLR::GetHeight (double x, double y) const
187 {
188  double z = 0.0;
189 
190  if (x_start_<=x && x<=x_end1_)
191  z = slope_*(y-y_start_);
192 
193  if (x_end1_<=x && x<=x_end2_)
194  z = -slope_*(y+y_start_);
195 
196  return z;
197 }
198 
199 double
200 ChimneyLR::GetHeightDerivWrtY (double x, double y) const
201 {
202  double dzdy = 0.0;
203 
204  if (x_start_ <= x && x <= x_end1_)
205  dzdy = slope_;
206 
207  if (x_end1_<=x && x<=x_end2_)
208  dzdy = -slope_;
209 
210  return dzdy;
211 }
212 
213 } /* namespace towr */
double GetHeight(double x, double y) const override
double GetHeight(double x, double y) const override
double GetHeight(double x, double y) const override
double GetHeightDerivWrtY(double x, double y) const override
FlatGround(double height=0.0)
double GetHeightDerivWrtXX(double x, double y) const override
double GetHeightDerivWrtX(double x, double y) const override
double GetHeightDerivWrtX(double x, double y) const override
double GetHeight(double x, double y) const override
double GetHeightDerivWrtY(double x, double y) const override
double GetHeight(double x, double y) const override
double GetHeightDerivWrtX(double x, double y) const override
double GetHeight(double x, double y) const override


towr
Author(s): Alexander W. Winkler
autogenerated on Mon Feb 28 2022 23:54:22