Exemple #1
0
        private void SetAveragePosition(NeighbourTransferSection section)
        {
            {
                if (!section.InitializedPosition)
                {
                    section.CurrentPosition     = (section.LowerBound + section.UpperBound) / 2;
                    section.InitializedPosition = true;
                }
                if (section.Particles.Count() == 0)
                {
                    section.CurrentPosition = (6 * section.CurrentPosition + section.LowerBound + section.UpperBound) / 8;
                    return;
                }
                var particleAverage = new Vector3();
                particleAverage = section.Particles.Aggregate(particleAverage, (current, particle) => current + particle.Position) / section.Particles.Count();
                var flexibility = 1 - section.LocationStifness;

                section.CurrentPosition = section.CurrentPosition * section.LocationInertia + (1 - section.LocationInertia) * (particleAverage * flexibility + section.LocationStifness * (section.LowerBound + section.UpperBound) / 2);
                if (section.CurrentPosition.X > 1)
                {
                    Console.Out.WriteLine("ola");
                }

                section.CurrentPosition = new Vector3(section.CurrentPosition.X, (section.LowerBound.Y + section.UpperBound.Y) / 2, section.CurrentPosition.Z);;
            }
        }
Exemple #2
0
        public float[] CalculatedSingleDimDif(Vector3 particlePosition, Vector3 sectionPosition,
                                              NeighbourTransferSection section)
        {
            var dDif = new float[6];

            dDif[0] = Math.Abs(particlePosition.X - sectionPosition.X) -
                      Math.Abs(particlePosition.X - section.NeighbourPositions[0].X);
            dDif[1] = Math.Abs(particlePosition.X - sectionPosition.X) -
                      Math.Abs(particlePosition.X - section.NeighbourPositions[1].X);

            dDif[2] = Math.Abs(particlePosition.Y - sectionPosition.Y) -
                      Math.Abs(particlePosition.Y - section.NeighbourPositions[2].Y);
            dDif[3] = Math.Abs(particlePosition.Y - sectionPosition.Y) -
                      Math.Abs(particlePosition.Y - section.NeighbourPositions[3].Y);

            dDif[4] = Math.Abs(particlePosition.Z - sectionPosition.Z) -
                      Math.Abs(particlePosition.Z - section.NeighbourPositions[4].Z);
            dDif[5] = Math.Abs(particlePosition.Z - sectionPosition.Z) -
                      Math.Abs(particlePosition.Z - section.NeighbourPositions[5].Z);
            return(dDif);
        }