pub fn at(&self, pos: [f64; 2]) -> [f64; 2] {
        use vecmath::vec2_add as add;
        use vecmath::vec2_sub as sub;
        use vecmath::vec2_len as len;
        use vecmath::vec2_scale as scale;

        if self.arrows.len() == 0 { return [0.0; 2]; }

        let mut sum = [0.0; 2];
        let mut sum_w = 0.0;
        for (i, arrow) in self.arrows.iter().enumerate() {
            let l = len(sub(arrow.pos, pos)).max(0.01);
            let w = 1.0 / (l * l);
            let phase_w = self.arrow_phases[i].cos();
            sum = add(sum, scale(arrow.dir, w * phase_w));
            sum_w += w;
        }

        scale(sum, 1.0 / sum_w)
    }
/// Computes stream at position using weighted average
Computes stream at position using weighted average
Computes stream at position using weighted average
pub fn at(&self, pos: [f64; 2]) -> [f64; 2] {
        use vecmath::vec2_add as add;
        use vecmath::vec2_sub as sub;
        use vecmath::vec2_len as len;
        use vecmath::vec2_scale as scale;
        if self.arrows.len() == 0 { return [0.0; 2]; }
        let mut sum = [0.0; 2];
        let mut sum_w = 0.0;
        for (i, arrow) in self.arrows.iter().enumerate() {
            let l = len(sub(arrow.pos, pos)).max(0.01);
            let w = 1.0 / (l * l);
            let phase_w = self.arrow_phases[i].cos();
            sum = add(sum, scale(arrow.dir, w * phase_w));
            sum_w += w;
        }
        scale(sum, 1.0 / sum_w)
    }
pub fn at ( & self , pos : [ f64 ; 2 ] ) -> [ f64 ; 2 ] { use vecmath :: vec2_add as add ; use vecmath :: vec2_sub as sub ; use vecmath :: vec2_len as len ; use vecmath :: vec2_scale as scale ; if self . arrows . len ( ) == 0 { return [ 0.0 ; 2 ] ; } let mut sum = [ 0.0 ; 2 ] ; let mut sum_w = 0.0 ; for ( i , arrow ) in self . arrows . iter ( ) . enumerate ( ) { let l = len ( sub ( arrow . pos , pos ) ) . max ( 0.01 ) ; let w = 1.0 / ( l * l ) ; let phase_w = self . arrow_phases [ i ] . cos ( ) ; sum = add ( sum , scale ( arrow . dir , w * phase_w ) ) ; sum_w += w ; } scale ( sum , 1.0 / sum_w ) }
Computes stream at position using weighted average
Computes stream at position using weighted average
&self
pos
[f64; 2]