Skip to main content

Profile

Enum Profile 

Source
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.25

Exhaustive 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.

Fields

§pitch: f32

Rise over run. 1.0 gives 45°, 0.0 gives a flat 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.

Fields

§lower_pitch: f32

Rise over run below the break.

§break_offset: f32

How far from the eaves the pitch changes, in plan units.

§upper_pitch: f32

Rise over run above the break.

Implementations§

Source§

impl Profile

Source

pub fn height_at(self, offset: f32) -> f32

The height at a given distance from the eaves.

Trait Implementations§

Source§

impl Clone for Profile

Source§

fn clone(&self) -> Profile

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Profile

Source§

impl Debug for Profile

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for Profile

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Profile

Source§

fn eq(&self, other: &Profile) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for Profile

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Profile

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.