예제 #1
0
        public PythonSegment NewSegment()
        {
            PythonSegment ps = new PythonSegment(this.x, this.y, this.parent);

            ps.NewQueue(new Queue <Point>(this.Path), new Queue <double>(this.Range));
            this.parent.Body.Add(ps);
            this.parent.Link();
            return(ps);
        }
예제 #2
0
        public void Control()
        {
            Point cursor = Program.GlobalForm.GetCusor();

            this.Body[0].Speed = this.speed;
            this.Body[0].Control();
            this.Path.Add(this.newPoint);
            this.Range.Add(this.speed);
            for (int i = 1; i < this.Body.Count; i++)
            {
                PythonSegment p = this.Body[i];
                //p.Speed=this.speed;
                p.Control();
            }
            double mdr = this.segmentRange;
            int    seg = 1;
            PointF pf  = this.Path[0];
            double npr = 0;

            for (int i = this.Range.Count - 1; i > -1; i--)
            {
                if (seg == this.Body.Count)
                {
                    pf = this.Path[i];
                    this.Path.RemoveRange(0, i + 1);
                    this.Range.RemoveRange(0, i + 1);
                    this.Path.Insert(0, new PointF((float)this.Body[seg - 1].X, (float)this.Body[seg - 1].Y));
                    this.Range.Insert(0, npr);
                }
                else if (mdr < this.Range[i])
                {
                    double d   = mdr / this.Range[i];
                    double mdx = d * (this.Path[i].X - this.Path[i + 1].X);
                    double mdy = d * (this.Path[i].Y - this.Path[i + 1].Y);
                    double x   = this.Path[i + 1].X + mdx;
                    double y   = this.Path[i + 1].Y + mdy;
                    this.Body[seg].Place(x, y);
                    seg++;
                    npr = mdr = this.segmentRange + Math.Sqrt(mdx * mdx + mdy * mdy);
                    i++;
                }
                else
                {
                    mdr -= this.Range[i];
                }
            }
            for (int i = seg; i < this.Body.Count; i++)
            {
                this.Body[i].Place(pf.X, pf.Y);
            }
        }