Ejemplo n.º 1
0
        public void UpdateGeometry(double localGrowthAngleStart, double growthLengthStart,
                                   double localGrowthAngleEnd, double growthLengthEnd)
        {
            // End tip
            double globalAngleEnd = MathUtilities.WrapAngle(localGrowthAngleEnd + endTipSystem.RotationAngle);
            double dxEnd          = growthLengthEnd * Math.Cos(globalAngleEnd);
            double dyEnd          = growthLengthEnd * Math.Sin(globalAngleEnd);
            var    oldEndTip      = Vertices.Last.Value;;
            var    newEndTip      = new CartesianPoint(oldEndTip.X + dxEnd, oldEndTip.Y + dyEnd);

            Vertices.AddLast(newEndTip);
            Segments.AddLast(new DirectedSegment2D(oldEndTip, newEndTip));
            Angles.AddLast(localGrowthAngleEnd); // These are independent of the global coordinate system
            endTipSystem = new TipCoordinateSystem(newEndTip, globalAngleEnd);

            //StartTip
            double globalAngleStart = MathUtilities.WrapAngle(localGrowthAngleStart + startTipSystem.RotationAngle);
            double dxStart          = growthLengthStart * Math.Cos(globalAngleStart);
            double dyStart          = growthLengthStart * Math.Sin(globalAngleStart);
            var    oldStartTip      = Vertices.First.Value;
            var    newStartTip      = new CartesianPoint(oldStartTip.X + dxEnd, oldStartTip.Y + dyEnd);

            Vertices.AddFirst(newStartTip);
            Segments.AddFirst(new DirectedSegment2D(newStartTip, oldStartTip));
            Angles.AddFirst(-localGrowthAngleEnd); // From new to old start segment, use the opposite angle
            endTipSystem = new TipCoordinateSystem(newStartTip, globalAngleStart);
        }