pub fn bounce(&mut self, other: &mut Human) {
        let tangent_vector = Vector::normalize(self.pos.y - other.pos.y, -(self.pos.x - other.pos.x));

        let relative_velocity = self.velocity - other.velocity;

        let length = relative_velocity.dot(&tangent_vector);

        let velocity_component_on_tangent = tangent_vector.scale(length);

        let velocity_component_perpendicular_to_tangent = relative_velocity - velocity_component_on_tangent;

        self.velocity = self.velocity - velocity_component_perpendicular_to_tangent;
        other.velocity = other.velocity + velocity_component_perpendicular_to_tangent;
    }
/// Calculate new velocity of collision between two humans
Calculate new velocity of collision between two humans
Calculate new velocity of collision between two humans
pub fn bounce(&mut self, other: &mut Human) {
        let tangent_vector = Vector::normalize(self.pos.y - other.pos.y, -(self.pos.x - other.pos.x));
        let relative_velocity = self.velocity - other.velocity;
        let length = relative_velocity.dot(&tangent_vector);
        let velocity_component_on_tangent = tangent_vector.scale(length);
        let velocity_component_perpendicular_to_tangent = relative_velocity - velocity_component_on_tangent;
        self.velocity = self.velocity - velocity_component_perpendicular_to_tangent;
        other.velocity = other.velocity + velocity_component_perpendicular_to_tangent;
    }
pub fn bounce ( & mut self , other : & mut Human ) { let tangent_vector = Vector :: normalize ( self . pos . y - other . pos . y , - ( self . pos . x - other . pos . x ) ) ; let relative_velocity = self . velocity - other . velocity ; let length = relative_velocity . dot ( & tangent_vector ) ; let velocity_component_on_tangent = tangent_vector . scale ( length ) ; let velocity_component_perpendicular_to_tangent = relative_velocity - velocity_component_on_tangent ; self . velocity = self . velocity - velocity_component_perpendicular_to_tangent ; other . velocity = other . velocity + velocity_component_perpendicular_to_tangent ; }
Calculate new velocity of collision between two humans
Calculate new velocity of collision between two humans
&mut self
other
&mut Human
&mut self
other
&mut Human