Beispiel #1
0
        /// <summary>
        /// The squared distance does not require the square root. Hence, it is
        /// computationally more efficient than the distance.
        /// </summary>
        /// <param name="self"></param>
        /// <param name="other"></param>
        /// <returns></returns>
        public static double GetSquaredDistanceToPrimaryParticle(this PrimaryParticle self, PrimaryParticle other)
        {
            var x = Math.Pow(self.Position.X - other.Position.X, 2);
            var y = Math.Pow(self.Position.Y - other.Position.Y, 2);
            var z = Math.Pow(self.Position.Z - other.Position.Z, 2);

            return(Math.Round(x + y + z, 6));
        }
Beispiel #2
0
        public static double GetDistanceToPosition(this PrimaryParticle self, Vector3 other)
        {
            var x        = Math.Pow(self.Position.X - other.X, 2);
            var y        = Math.Pow(self.Position.Y - other.Y, 2);
            var z        = Math.Pow(self.Position.Z - other.Z, 2);
            var distance = Math.Round(Math.Sqrt(x + y + z), 6);

            return(distance);
        }
Beispiel #3
0
        public INeighborslist BuildEmpty3DNeighborsList()
        {
            // The neighborslist requires a particle to be build. Therefore, a dummy particle
            // which can never be reached is added to the neighborslist
            // this particle will never show up in an aggregate
            var dummyPP = new PrimaryParticle(-1, new Vector3(-999999, -999999, -999999), 0);

            return(new Accord3DNeighborslist(new List <PrimaryParticle> {
                dummyPP
            }));
        }
Beispiel #4
0
 private void CheckPeriodicBoundary(PrimaryParticle virtualParticle, double oneDPosition, double maxRadius, BoxDimension dim)
 {
     if (oneDPosition + virtualParticle.Radius >= dim.Upper - maxRadius)
     {
         virtualParticle.Position.X -= dim.Width;
         AddParticlesToNeighborsList(virtualParticle);
     }
     else if (oneDPosition - virtualParticle.Radius <= dim.Lower + maxRadius)
     {
         virtualParticle.Position.X += dim.Width;
         AddParticlesToNeighborsList(virtualParticle);
     }
 }
Beispiel #5
0
 /// <summary>
 /// A virtual particle is only within the neighborslist to ensure that any
 /// particle that would hit another particle through periodic boundary conditions
 /// can see this virtual particle
 /// </summary>
 /// <param name="primaryParticle"></param>
 /// <returns></returns>
 private PrimaryParticle GetVirtualParticle(PrimaryParticle primaryParticle)
 {
     return(new PrimaryParticle
     {
         Id = -1 * primaryParticle.Id,
         Position = new Vector3
                    (
             primaryParticle.Position.X,
             primaryParticle.Position.Y,
             primaryParticle.Position.Z
                    ),
         Radius = primaryParticle.Radius
     });
 }
Beispiel #6
0
 public virtual void AddParticlesToNeighborsList(PrimaryParticle primaryParticle)
 {
     _kdTree.Add(primaryParticle.Position.ToArray(), primaryParticle);
 }
Beispiel #7
0
 public override void AddParticlesToNeighborsList(PrimaryParticle primaryParticle)
 {
     _kdTree.Add(primaryParticle.Position.ToXYArray(), primaryParticle);
 }
Beispiel #8
0
 public static double GetDistanceToVerticalAxis(this PrimaryParticle primaryParticle, PrimaryParticle neighbor)
 {
     return(Math.Sqrt(Math.Pow(primaryParticle.Position.X - neighbor.Position.X, 2) +
                      Math.Pow(primaryParticle.Position.Y - neighbor.Position.Y, 2)
                      ));
 }
Beispiel #9
0
 public static double GetDistanceToVerticalAxis(this PrimaryParticle primaryParticle, double[] neighborPosition)
 {
     return(Math.Sqrt(Math.Pow(primaryParticle.Position.X - neighborPosition[0], 2) +
                      Math.Pow(primaryParticle.Position.Y - neighborPosition[1], 2)
                      ));
 }