Пример #1
0
        private void UnevenCoordinates()
        {
            double x, y, z;
            double random;
            double func;
            double distancefromcenter;
            int    createdpoints = 0;

            while (createdpoints < counterofpoints)
            {
                x = radius * (1 - 2 * SphereStarCluster.dRand(0, 1));
                y = radius * (1 - 2 * SphereStarCluster.dRand(0, 1));
                z = radius * (1 - 2 * SphereStarCluster.dRand(0, 1));
                distancefromcenter = Math.Pow(x, 2) + Math.Pow(y, 2) + Math.Pow(z, 2);
                random             = SphereStarCluster.dRand(0, 1);
                func = Math.Sqrt(distancefromcenter) / radius;
                if (Math.Pow(radius, 2) >= distancefromcenter && random > func)
                {
                    this.x[createdpoints] = x;
                    this.y[createdpoints] = y;
                    this.z[createdpoints] = z;
                    createdpoints++;
                }
            }
        }
Пример #2
0
 private void RandomizeMasses()
 {
     for (int i = 0; i < counterofpoints; i++)
     {
         masses[i]    = SphereStarCluster.dRand(1, 2) * 2e30;
         massesSigma += masses[i];
     }
 }
Пример #3
0
 private void RandomizeVelocities()
 {
     for (int i = 0; i < counterofpoints; i++)
     {
         vx[i] = SphereStarCluster.dRand(-1, 1) * 1e2;
         vy[i] = SphereStarCluster.dRand(-1, 1) * 1e2;
         vz[i] = SphereStarCluster.dRand(-1, 1) * 1e2;
     }
 }
Пример #4
0
        private void RandomizeCoordinates()
        {
            double x, y, z;
            double distancefromcenter;
            int    createdpoints = 0;

            while (createdpoints < counterofpoints)
            {
                x = radius * (1 - 2 * SphereStarCluster.dRand(0, 1));
                y = radius * (1 - 2 * SphereStarCluster.dRand(0, 1));
                z = radius * (1 - 2 * SphereStarCluster.dRand(0, 1));
                distancefromcenter = Math.Pow(x, 2) + Math.Pow(y, 2) + Math.Pow(z, 2);
                if (Math.Pow(radius, 2) >= distancefromcenter)
                {
                    this.x[createdpoints] = x;
                    this.y[createdpoints] = y;
                    this.z[createdpoints] = z;
                    createdpoints++;
                }
            }
        }