Exemplo n.º 1
0
        public override void interactWith(Obstacle obstacle)
        {
            // Get vertex
            Obstacle obstacle2 = obstacle.next_;
            // Distance to the vertex
            Vector2 vector2Vertex = Vector2.vectorToSegment(obstacle.point_, obstacle2.point_, position_);
            // w_phi enables to deal with elliptical forces
            float w_phi = 1;
            float test  = motion_dir_ * Vector2.normalize(vector2Vertex);

            if (type_ == 1)
            {
                //w_phi = lambda_ + (1 - lambda_)*(1+motion_dir_*normalize(vector2Vertex)/2);
                w_phi = (float)(Math.Pow(test + 1, lambda_) / Math.Pow(2, lambda_));
            }
            // Compute force
            float   exp_term = (radius_ - Vector2.abs(vector2Vertex)) / B_;
            Vector2 force    = w_phi * A_ * (float)Math.Exp(exp_term) * -1 * Vector2.normalize(vector2Vertex) / m_;

            // Body force
            if (Vector2.abs(vector2Vertex) < radius_)
            {
                force += k_ * (radius_ - Vector2.abs(vector2Vertex)) * -1 * Vector2.normalize(vector2Vertex) / m_;
            }
            acceleration_ += force;
        }