#[non_exhaustive]pub enum ElevationLaw {
Polynomial {
coefficients: Vec<Scalar>,
},
Piecewise {
breaks: Vec<Scalar>,
laws: Vec<ElevationLaw>,
},
}Expand description
Height as a function of distance along the plan.
Mirrors CurvatureLaw in shape so the two halves of
an alignment read the same way, but stays a separate type: a curvature law
is a property of a planar curve and an elevation law is not, and sharing one
enum would make a meaningless pairing representable.
Dirty imported data stays representable, as everywhere else in this crate.
Mismatched piece lists report None rather than guessing.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Polynomial
z(d) = coefficients[0] + coefficients[1] * d + coefficients[2] * d^2 + ...
Degree 1 is a constant gradient, degree 2 the parabolic vertical curve used to join two grades. Those are the two vertical segment kinds that carry most alignment data, and both are exact here.
An empty coefficient list is the zero polynomial: height zero.
Piecewise
Pieces laid end to end along plan distance, each with its own law.
breaks holds the INTERIOR seam positions measured from the start, so
laws.len() == breaks.len() + 1 and piece i spans
breaks[i - 1] .. breaks[i].
Each piece’s law is written in its OWN distance, restarting at zero at
its seam, so moving a piece never rewrites its coefficients. This
matches CurvatureLaw::Piecewise
deliberately: a vertical profile is authored as a run of segments and
the seams are observable data.
Implementations§
Source§impl ElevationLaw
impl ElevationLaw
Sourcepub fn constant_grade(height: Scalar, grade: Scalar) -> Self
pub fn constant_grade(height: Scalar, grade: Scalar) -> Self
A constant gradient: z(d) = height + grade * d.
Sourcepub fn parabolic(
height: Scalar,
entry_grade: Scalar,
exit_grade: Scalar,
length: Scalar,
) -> Self
pub fn parabolic( height: Scalar, entry_grade: Scalar, exit_grade: Scalar, length: Scalar, ) -> Self
A parabolic vertical curve joining entry_grade to exit_grade over
length.
The rate of change of grade is (exit - entry) / length, so
z(d) = height + entry * d + (exit - entry) / (2 * length) * d^2.
A non-positive length is storable; naming it is a validator’s job.
Sourcepub fn is_well_formed(&self) -> bool
pub fn is_well_formed(&self) -> bool
Whether the piece lists agree and the seams ascend.
Trait Implementations§
Source§impl Clone for ElevationLaw
impl Clone for ElevationLaw
Source§fn clone(&self) -> ElevationLaw
fn clone(&self) -> ElevationLaw
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more