Ejemplo n.º 1
0
 /// <summary>
 /// Creates a particle engine using the specified generator.
 /// </summary>
 /// <param name="particleGenerator">The particle generator to use.</param>
 public ParticleEngine(IParticleGenerator particleGenerator)
 {
     if (particleGenerator == null)
     {
         throw new ArgumentNullException("particleGenerator");
     }
     _generator = particleGenerator;
 }
Ejemplo n.º 2
0
 public ParticleEmitter(IParticleGenerator gen, Vector2 location, int generationCount = 10)
     : base()
 {
     Position = location;
     GenerationCount = generationCount;
     Particles = new List<Particle>();
     Generator = gen;
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 设置粒子生成器
 /// </summary>
 /// <param name="generator"></param>
 public virtual void SetParticleGenerator(IParticleGenerator generator)
 {
     _generator = generator;
     if (_generator != null)
     {
         _emitter.AttachGenerator(_generator);
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PositionParticleFilter"/> class.
 /// </summary>
 /// <param name="noiseGenerator">See noiseGenerator argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="resampleNoiseSize">See resampleNoiseSize argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="resampler">See resampler argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="particleGenerator">See particleGenerator argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="particleAmount">See particleAmount argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="fieldSize">The dimensions of the area where the user can be.</param>
 /// <param name="smoother">See smoother argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 public PositionParticleFilter(
     INoiseGenerator noiseGenerator,
     float resampleNoiseSize,
     IResampler resampler,
     IParticleGenerator particleGenerator,
     int particleAmount,
     FieldSize fieldSize,
     ISmoother smoother)
     : base(
         resampler,
         noiseGenerator,
         new LinearParticleController(particleGenerator, particleAmount, fieldSize.Xmin, fieldSize.Xmax),
         new LinearParticleController(particleGenerator, particleAmount, fieldSize.Ymin, fieldSize.Ymax),
         new LinearParticleController(particleGenerator, particleAmount, fieldSize.Zmin, fieldSize.Zmax),
         resampleNoiseSize,
         smoother,
         Enumerable.Average)
 {
     this.displacementSources = new List <IDisplacementSource>();
     this.positionSources     = new List <IPositionSource>();
     this.iex = new LinearRegression();
     this.iey = new LinearRegression();
     this.iez = new LinearRegression();
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParticleFilter"/> class.
 /// </summary>
 /// <param name="noiseGenerator">See noiseGenerator argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="resampleNoiseSize">See resampleNoiseSize argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="resampler">See resampler argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="particleGenerator">See particleGenerator argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="particleAmount">See particleAmount argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="fieldSize">The dimensions of the area where the user can be.</param>
 /// <param name="smoother">See smoother argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 public ParticleFilter(int particleAmount, float resampleNoiseSize, FieldSize fieldSize, IParticleGenerator particleGenerator, IResampler resampler, INoiseGenerator noiseGenerator, ISmoother smoother)
 {
     this.posReceivers      = new List <IPositionFeedbackReceiver>();
     this.oriReceivers      = new List <IOrientationFeedbackReceiver>();
     this.positionFilter    = new PositionParticleFilter(noiseGenerator, resampleNoiseSize, resampler, particleGenerator, particleAmount, fieldSize, smoother);
     this.orientationFilter = new OrientationParticleFilter(noiseGenerator, resampleNoiseSize, resampler, particleGenerator, particleAmount, smoother.Clone());
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="LinearParticleController"/> class.
 /// </summary>
 /// <param name="particleGenerator">The class used to generate new particles</param>
 /// <param name="particleAmount">The amount of particles</param>
 /// <param name="minValue">The minimum value that a particle can have</param>
 /// <param name="maxValue">The maximum value that a particle can have</param>
 public LinearParticleController(IParticleGenerator particleGenerator, int particleAmount, float minValue, float maxValue)
     : base(particleAmount, minValue, maxValue, particleGenerator)
 {
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OrientationParticleFilter"/> class.
 /// </summary>
 /// <param name="noiseGenerator">See noiseGenerator argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="resampleNoiseSize">See resampleNoiseSize argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="resampler">See resampler argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="particleGenerator">See particleGenerator argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="particleAmount">See particleAmount argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 /// <param name="smoother">See smoother argument of the constructor of <seealso cref="AbstractParticleFilter"/></param>
 public OrientationParticleFilter(INoiseGenerator noiseGenerator, float resampleNoiseSize, IResampler resampler, IParticleGenerator particleGenerator, int particleAmount, ISmoother smoother)
     : base(
         resampler,
         noiseGenerator,
         new CircularParticleController(particleGenerator, particleAmount),
         new CircularParticleController(particleGenerator, particleAmount),
         new CircularParticleController(particleGenerator, particleAmount),
         resampleNoiseSize,
         smoother,
         AngleMath.Average)
 {
     this.orientationSources = new List <IOrientationSource>();
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AbstractParticleController"/> class.
 /// </summary>
 /// <param name="particleAmount"><see cref="Count"/></param>
 /// <param name="minValue"><see cref="MinValue"/></param>
 /// <param name="maxValue"><see cref="MaxValue"/></param>
 /// <param name="particleGenerator">The class used to create the initial collection of particle values.</param>
 protected AbstractParticleController(int particleAmount, float minValue, float maxValue, IParticleGenerator particleGenerator)
 {
     this.MaxValue      = maxValue;
     this.MinValue      = minValue;
     this.WeightsVector = new DenseVector(Enumerable.Repeat(1f / particleAmount, particleAmount).ToArray());
     this.ValuesVector  = new DenseVector(particleAmount);
     this.ValuesVector.SetValues(particleGenerator.Generate(particleAmount, minValue, maxValue));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CircularParticleController"/> class.
 /// </summary>
 /// <param name="particleGenerator">See the parameter particleGenerator of <seealso cref="AbstractParticleController"/></param>
 /// <param name="particleAmount">See the parameter particleAmount of <seealso cref="AbstractParticleController"/></param>
 public CircularParticleController(IParticleGenerator particleGenerator, int particleAmount)
     : base(particleAmount, MinAngle, MaxAngle, particleGenerator)
 {
 }
Ejemplo n.º 10
0
 /// <summary>
 /// 绑定粒子生成器
 /// </summary>
 /// <param name="generator"></param>
 public virtual void AttachGenerator(IParticleGenerator generator)
 {
     _generator = generator;
 }