fn average_width(&self) -> f32 {
        // TODO: Are the width values of the first and second point always the same?

        // Algorithm for weighted average see e.g. notes by Tony Finch:
        // Incremental calculation of weighted mean and variance, chapter 4
        // https://fanf2.user.srcf.net/hermes/doc/antiforgery/stats.pdf#page=3
        let mut average_width = 0.0;
        let mut total_length = 0.0;
        for (i, point) in self.points[1..].iter().enumerate() {
            let segment_length = self.segment_length(i).unwrap_or_else(|_| unreachable!());
            total_length += segment_length;
            average_width += segment_length / total_length * (point.width - average_width);
        }
        average_width
    }
/// Average of each segment's width, weighted by the segment length.
/// Primarily useful for rendering to targets requiring a fixed line width.
Average of each segment's width, weighted by the segment length.
Primarily useful for rendering to targets requiring a fixed line width.
Average of each segment ' s width weighted by the segment length . Primarily useful for rendering to targets requiring a fixed line width .
fn average_width(&self) -> f32 {
        // TODO: Are the width values of the first and second point always the same?
        // Algorithm for weighted average see e.g. notes by Tony Finch:
        // Incremental calculation of weighted mean and variance, chapter 4
        // https://fanf2.user.srcf.net/hermes/doc/antiforgery/stats.pdf#page=3
        let mut average_width = 0.0;
        let mut total_length = 0.0;
        for (i, point) in self.points[1..].iter().enumerate() {
            let segment_length = self.segment_length(i).unwrap_or_else(|_| unreachable!());
            total_length += segment_length;
            average_width += segment_length / total_length * (point.width - average_width);
        }
        average_width
    }
fn average_width ( & self ) -> f32 { // TODO: Are the width values of the first and second point always the same? // Algorithm for weighted average see e.g. notes by Tony Finch: // Incremental calculation of weighted mean and variance, chapter 4 // https://fanf2.user.srcf.net/hermes/doc/antiforgery/stats.pdf#page=3 let mut average_width = 0.0 ; let mut total_length = 0.0 ; for ( i , point ) in self . points [ 1 .. ] . iter ( ) . enumerate ( ) { let segment_length = self . segment_length ( i ) . unwrap_or_else ( | _ | unreachable ! ( ) ) ; total_length += segment_length ; average_width += segment_length / total_length * ( point . width - average_width ) ; } average_width }
Average of each segment's width, weighted by the segment length.
Average of each segment ' s width weighted by the segment length .
&self
&self