FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
ParametricBathymetry.h
1#pragma once
2
3#include <marenv/seafloor/BathymetryField.h>
4
5#include <memory>
6#include <string>
7#include <vector>
8
9namespace marenv::seafloor
10{
11
13namespace parametric
14{
15
23enum class Primitive
24{
25 Constant,
26 Slope,
28 Valley,
29 Peak,
30 Bump,
32};
33
35enum class InterpMode
36{
37 Linear,
40};
41
43enum class Extrap
44{
45 Flat,
46 Linear,
47 Extend
48};
49
56{
59 std::vector<double> nodes;
60 std::vector<double> values;
61
62 // Precomputed coefficients (populated by the builder in the .cpp).
63 std::vector<double> poly;
64 std::vector<double> b;
65 std::vector<double> c;
66 std::vector<double> d;
67
73 [[nodiscard]] double Evaluate(double v) const;
74};
75
77enum class Shape
78{
79 Gaussian,
80 Parabola,
81 Cosine
82};
83
85enum class Window
86{
87 Hard,
88 Linear,
91};
92
94enum class Blend
95{
96 Replace,
97 Add,
98 Min,
99 Max
100};
101
107{
109 double headingRad = 0.0;
110 double cosHeading = 1.0;
111 double sinHeading = 0.0;
112 double depth = 200.0;
113 double gradient = 0.0;
114 double amplitude = 0.0;
115 double width = 1.0;
116 double crossOffset = 0.0;
117 double centerX = 0.0;
118 double centerY = 0.0;
120
121 std::shared_ptr<const Profile1D> profile;
122};
123
128struct Region
129{
130 double headingRad = 0.0;
131 double cosHeading = 1.0;
132 double sinHeading = 0.0;
133 double min = -1.0e300;
134 double max = 1.0e300;
135};
136
144
147{
148 double length = 100.0;
150};
151
160struct Track
161{
162 bool present = false;
163 double headingRad = 0.0;
164 double cosHeading = 1.0;
165 double sinHeading = 0.0;
166 double start = 0.0;
167 double transitionWidth = 0.0;
169 std::vector<Segment> segments;
170};
171
173struct Spec
174{
175 double baseDepth = 200.0;
176 double rho = 2000.0;
178 std::vector<Layer> layers;
179};
180
181} // namespace parametric
182
203{
204public:
210 ~ParametricBathymetry() override = default;
211
213 [[nodiscard]] marenv::Status GetDepth(const double pos[2], double& depthOut) override;
214
216 [[nodiscard]] marenv::Status ComputeSurfaceUnitNormal(const double pos[2], double unitNormalOut[3]) override;
217
219 [[nodiscard]] marenv::Status GetSoilState(const double pos[3], SoilState& soilOut) override;
220
227 [[nodiscard]] double DepthAt(double x, double y) const;
228
229private:
230 double TrackDepth(double x, double y) const;
231
232 parametric::Spec m_spec;
233};
234
235} // namespace marenv::seafloor
Definition BathymetryField.h:25
Definition ParametricBathymetry.h:203
marenv::Status ComputeSurfaceUnitNormal(const double pos[2], double unitNormalOut[3]) override
double DepthAt(double x, double y) const
ParametricBathymetry(parametric::Spec spec)
marenv::Status GetSoilState(const double pos[3], SoilState &soilOut) override
marenv::Status GetDepth(const double pos[2], double &depthOut) override
Status
Definition marenv.h:44
Window
Edge profiles of the cross-fade between track segments.
Definition ParametricBathymetry.h:86
@ Smoothstep
Cubic smoothstep ramp.
@ Hard
Discontinuous 0/1 gate.
@ RaisedCosine
Raised-cosine ramp (partition-of-unity between neighbours).
Extrap
Behaviour of a 1-D profile outside its node range.
Definition ParametricBathymetry.h:44
@ Extend
Continue the interpolant/polynomial itself (may diverge).
@ Flat
Clamp to the nearest end value (constant beyond the range).
Blend
How a layer's weighted primitive combines with the accumulated depth.
Definition ParametricBathymetry.h:95
@ Replace
Linear blend toward the primitive by the region weight.
@ Max
Blend toward the deeper (larger depth) of the two.
@ Min
Blend toward the shallower (smaller depth) of the two.
@ Add
Add the weighted primitive value.
Primitive
Definition ParametricBathymetry.h:24
@ TransversalInterp
Cross-track profile interpolated through user-specified points.
@ Valley
Trough extruded along the heading (deeper toward the centre-line).
@ Peak
Ridge extruded along the heading (shallower toward the centre-line).
@ Bump
Localised radial feature centred at a point.
@ TransversalSlope
Inclined plane, gradient across the heading direction.
@ Slope
Inclined plane, gradient along the heading direction.
InterpMode
Interpolation method for a 1-D transversal profile.
Definition ParametricBathymetry.h:36
@ Polynomial
Single canonical (monomial) polynomial through all points.
@ Linear
Piecewise linear through the points.
@ CubicSpline
Piecewise cubic spline (natural, or clamped to zero end gradient).
Shape
One-dimensional profile shapes used by Valley/Peak/Bump primitives.
Definition ParametricBathymetry.h:78
@ Cosine
for , else 0 (finite support).
Definition SoilState.h:14
Definition ParametricBathymetry.h:107
double cosHeading
cos(headingRad); the ParametricBathymetry constructor fills it.
Definition ParametricBathymetry.h:110
double headingRad
Heading [rad], North toward East.
Definition ParametricBathymetry.h:109
Primitive type
Primitive kind.
Definition ParametricBathymetry.h:108
double centerY
Bump centre, East [m].
Definition ParametricBathymetry.h:118
double depth
Datum depth [m].
Definition ParametricBathymetry.h:112
double sinHeading
sin(headingRad); the ParametricBathymetry constructor fills it.
Definition ParametricBathymetry.h:111
double gradient
Slope [m/m] (Slope, TransversalSlope).
Definition ParametricBathymetry.h:113
double width
Characteristic width [m] (Valley/Peak/Bump).
Definition ParametricBathymetry.h:115
double amplitude
Feature amplitude [m] (Valley/Peak/Bump).
Definition ParametricBathymetry.h:114
Shape shape
Profile shape (Valley/Peak/Bump).
Definition ParametricBathymetry.h:119
std::shared_ptr< const Profile1D > profile
Interpolated cross-track profile (TransversalInterp).
Definition ParametricBathymetry.h:121
double crossOffset
Offset of the feature line [m].
Definition ParametricBathymetry.h:116
double centerX
Bump centre, North [m].
Definition ParametricBathymetry.h:117
A primitive applied over a region, combined by a blend operator.
Definition ParametricBathymetry.h:139
Feature feature
The primitive to apply.
Definition ParametricBathymetry.h:140
Region region
Where it is active.
Definition ParametricBathymetry.h:141
Blend blend
How it combines with the accumulator.
Definition ParametricBathymetry.h:142
Definition ParametricBathymetry.h:56
std::vector< double > values
Node values z_i.
Definition ParametricBathymetry.h:60
InterpMode mode
Interpolation method.
Definition ParametricBathymetry.h:57
std::vector< double > poly
Canonical polynomial coefficients (Polynomial).
Definition ParametricBathymetry.h:63
std::vector< double > nodes
Node coordinates v_i (ascending).
Definition ParametricBathymetry.h:59
Extrap extrap
Out-of-range behaviour.
Definition ParametricBathymetry.h:58
std::vector< double > c
Spline 2nd-order coefficients per node.
Definition ParametricBathymetry.h:65
std::vector< double > d
Spline 3rd-order coefficients per node.
Definition ParametricBathymetry.h:66
std::vector< double > b
Spline/linear 1st-order coefficients per node.
Definition ParametricBathymetry.h:64
Definition ParametricBathymetry.h:129
double max
Interval upper bound along the region axis [m].
Definition ParametricBathymetry.h:134
double headingRad
Region axis heading [rad].
Definition ParametricBathymetry.h:130
double sinHeading
sin(headingRad); the ParametricBathymetry constructor fills it.
Definition ParametricBathymetry.h:132
double min
Interval lower bound along the region axis [m].
Definition ParametricBathymetry.h:133
double cosHeading
cos(headingRad); the ParametricBathymetry constructor fills it.
Definition ParametricBathymetry.h:131
One along-track segment: a length and the cross-track profile it presents.
Definition ParametricBathymetry.h:147
double length
Along-track extent [m].
Definition ParametricBathymetry.h:148
Feature profile
Cross-track seabed profile for this segment.
Definition ParametricBathymetry.h:149
Definition ParametricBathymetry.h:174
std::vector< Layer > layers
Optional general composition layers (applied after the track).
Definition ParametricBathymetry.h:178
Track track
Optional along-track profile sequence.
Definition ParametricBathymetry.h:177
double baseDepth
Fallback depth where nothing else applies [m].
Definition ParametricBathymetry.h:175
double rho
Constant seabed density [kg/m^3].
Definition ParametricBathymetry.h:176
Definition ParametricBathymetry.h:161
Window transition
Cross-fade edge profile.
Definition ParametricBathymetry.h:168
double start
Along-track position of the first segment [m].
Definition ParametricBathymetry.h:166
std::vector< Segment > segments
Ordered segments.
Definition ParametricBathymetry.h:169
double headingRad
Track heading [rad], North toward East.
Definition ParametricBathymetry.h:163
double transitionWidth
Cross-fade width [m].
Definition ParametricBathymetry.h:167
double cosHeading
cos(headingRad); the ParametricBathymetry constructor fills it.
Definition ParametricBathymetry.h:164
double sinHeading
sin(headingRad); the ParametricBathymetry constructor fills it.
Definition ParametricBathymetry.h:165
bool present
Whether a track is configured.
Definition ParametricBathymetry.h:162