pub enum Profile {
Hip {
pitch: f32,
},
Mansard {
lower_pitch: f32,
break_offset: f32,
upper_pitch: f32,
},
}Expand description
How a roof’s height grows with distance from the eaves.
A straight skeleton gives the plan of a roof: where the hips, valleys and
ridges run. It does not say how high anything is — that is this. Height is a
function of one variable, Node::offset, because a skeleton node’s offset
is how far the wavefront had travelled to reach it, which is exactly the run
the roof has had to rise over.
So changing the roof style does not change the skeleton at all. A mansard
over a plan has the same hips and ridge as a hip roof over it; only z
differs.
§Examples
use straight_skeleton::Profile;
// A hip: one slope all the way up.
let hip = Profile::Hip { pitch: 0.5 };
assert_eq!(hip.height_at(10.0), 5.0);
// A mansard: steep to 10, then shallow.
let mansard = Profile::Mansard {
lower_pitch: 2.0,
break_offset: 10.0,
upper_pitch: 0.25,
};
assert_eq!(mansard.height_at(10.0), 20.0); // the break
assert_eq!(mansard.height_at(30.0), 25.0); // 20 + 20 * 0.25Exhaustive on purpose, unlike the crate’s error types: this is a value
callers are meant to match on, and a roof style they cannot handle is better
caught by the compiler than by a _ arm quietly treating it as something
else.
Variants§
Hip
One slope all the way to the ridge: z = offset * pitch.
The classic hip roof.
Mansard
Two slopes with a break between them: a mansard.
Steep from the eaves up to break_offset, shallow from there on. That
is what a mansard is for — the steep lower slope buys headroom in the
storey inside it, and the shallow upper one keeps the whole thing from
becoming absurdly tall.
The break is at a constant offset, which is a constant height
(break_offset * lower_pitch), so it comes out as a level line all the
way round the roof — the kerb a real mansard has.
Nothing stops upper_pitch being the steeper of the two; the type does
not police taste. Equal pitches reduce to a Profile::Hip.