Пример #1
0
        public bool processParticle()
        {
            ForceAngle = ForceAngle + (0.5f - RidgeHelpers.random.NextDouble()) * (Math.PI / 10);
            double x = Math.Cos(ForceAngle);
            double y = Math.Sin(ForceAngle);

            X = X + x;
            Y = Y + y;

            Height = Height - RidgeHelpers.random.NextDouble() * 0.005f;

            String coordSignature = "" + (int)X + "#" + (int)Y;

            if (X < 0 || X >= HeightMap.Length || Y < 0 || Y >= HeightMap.Length || Height < 0 || (!CreatedCoords.Contains(coordSignature) && HeightMap[(int)X][(int)Y] != null))
            {
                return(false);
            }

            if (HeightMap[(int)X][(int)Y] != null && HeightMap[(int)X][(int)Y] != 0)
            {
                GeoPoint geoPoint = new GeoPoint();
                geoPoint.X      = (int)X;
                geoPoint.Y      = (int)Y;
                geoPoint.Height = (float)Height;
                Ridge.Add(geoPoint);
            }
            HeightMap[(int)X][(int)Y] = (float)Height;

            float distanceToLastGaussion = (float)Math.Sqrt(Math.Pow(LastGaussionX - X, 2) + Math.Pow(LastGaussionY - Y, 2));

            if (distanceToLastGaussion >= GaussionDistance)
            {
                GaussionXs.Add(X);
                GaussionYs.Add(Y);
                GaussionAngle.Add(ForceAngle);

                LastGaussionX = X;
                LastGaussionY = Y;
            }

            CreatedCoords.Add(coordSignature);

            return(true);
        }
Пример #2
0
        public RidgeParticle(float?[][] heightMap, float x, float y, float forceAngle, float height, List <GeoPoint> ridge)
        {
            HeightMap = heightMap;

            X          = x;
            Y          = y;
            ForceAngle = forceAngle;
            Height     = height;
            String coordSignature = "" + (int)X + "#" + (int)Y;

            CreatedCoords.Add(coordSignature);

            heightMap[(int)x][(int)y] = height;

            GaussionXs.Add(X);
            GaussionYs.Add(Y);
            GaussionAngle.Add(ForceAngle);

            Ridge = ridge;
        }