示例#1
0
        static void setPreferredVelocities(RVOSimulator sim)
        {
            /*
               * Set the preferred velocity to be a vector of unit magnitude (speed) in the
               * direction of the goal.
               */
            #pragma omp parallel for
              for (int i = 0; i < sim.getNumAgents(); ++i) {
                Vector2 goalVector = goals[i] - sim.getAgentPosition(i);

                if ((goalVector.LengthSquared()) > 1.0f) {
                  goalVector = Vector2.Normalize(goalVector);
                }

                sim.setAgentPrefVelocity(i, goalVector);

                /*
                 * Perturb a little to avoid deadlocks due to perfect symmetry.
                 */

                float angle = (float)r.NextDouble() * 2.0f * (float)Math.PI ;
                float dist = (float)r.NextDouble() * 0.0001f ;

                sim.setAgentPrefVelocity(i, sim.getAgentPrefVelocity(i) +
                                          dist * new Vector2((float) Math.Cos(angle), (float)Math.Sin(angle)));
              }
        }
 void p_OnPickedLeftButton(SegmentInterceptInfo SegmentInterceptInfo)
 {
     destiny = SegmentInterceptInfo.ImpactPosition;
     for (int i = 0; i < Simulator.getNumAgents(); i++)
     {
         Simulator.setAgentPrefVelocity(i, Vector3.Normalize(destiny - Simulator.getAgentPosition(i)));
     }
 }
示例#3
0
        static void setPreferredVelocities(RVOSimulator sim)
        {
            for (int i = 0; i < sim.getNumAgents(); ++i) {
                Vector3 goalVector = goals[i] - sim.getAgentPosition(i);

                if ((goalVector.LengthSquared()) > 1.0f) {
                    goalVector = Vector3.Normalize(goalVector);
                }

                sim.setAgentPrefVelocity(i, goalVector);
            }
        }