Esempio n. 1
0
        public void AddNoize(double _maxNoize)
        {
            Random r   = new Random((int)DateTime.Now.Ticks);
            var    rnd = 0.5 - r.NextDouble();

            UpdSpeed(Miscelaneous.Rotate(SpeedInDouble, _maxNoize * rnd));
        }
Esempio n. 2
0
        public override void Interract(IParticle _particle, int _index)
        {
            var ptPos     = _particle.CoordinatesInDouble;
            var ptSpeed   = _particle.SpeedInDouble;
            var ptPosNext = ptSpeed + ptPos;

            var ptBordFirst  = Borders[_index].First;
            var ptBordSecond = Borders[_index].Second;

            var ang            = Miscelaneous.GetDegreeBetveen(ptPos, ptPosNext, ptBordFirst, ptBordSecond);
            var intersectionPt = Miscelaneous.IntersectionPoint(ptPos, ptPosNext, ptBordFirst, ptBordSecond);

            PairDouble newPos;

            if (_index == 0)
            {
                newPos = _particle.CoordinatesInDouble + new PairDouble(m_SizeX, 0);
                _particle.UpdCoordinates(newPos + _particle.SpeedInDouble);
            }
            if (_index == 1)
            {
                ang = -2 * ang;

                _particle.UpdCoordinates(Miscelaneous.Rotate(intersectionPt, ptPosNext, ang));
                _particle.UpdSpeed(Miscelaneous.Rotate(ptSpeed, ang));
            }
            if (_index == 2)
            {
                newPos = _particle.CoordinatesInDouble - new PairDouble(m_SizeX, 0);
                _particle.UpdCoordinates(newPos + _particle.SpeedInDouble);
            }
            if (_index == 3)
            {
                if (ang > 90)
                {
                    ang = 2 * (180 - ang);
                }
                else
                {
                    ang = -2 * ang;
                }
                _particle.UpdCoordinates(Miscelaneous.Rotate(intersectionPt, ptPosNext, ang));

                _particle.UpdSpeed(Miscelaneous.Rotate(ptSpeed, ang));
            }
        }
Esempio n. 3
0
        public int?Check(IParticle _particle)
        {
            for (int i = 0; i < Borders.Count; i++)
            {
                var pt1 = _particle.CoordinatesInDouble;
                var pt2 = _particle.SpeedInDouble + pt1;

                var pt3 = Borders[i].First;
                var pt4 = Borders[i].Second;

                var isIntersection = Miscelaneous.Intersect(pt1, pt2, (PairDouble)pt3, (PairDouble)pt4);

                if (isIntersection)
                {
                    return(i);
                }
            }
            return(null);
        }