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); }
public void InitializeGeometry(CartesianPoint startTip, CartesianPoint endTip) { double dx = endTip.X - startTip.X; double dy = endTip.Y - startTip.Y; double tangentSlope = Math.Atan2(dy, dx); endTipSystem = new TipCoordinateSystem(endTip, tangentSlope); startTipSystem = new TipCoordinateSystem(startTip, tangentSlope + Math.PI); Vertices.AddLast(startTip); Vertices.AddLast(endTip); Segments.AddLast(new DirectedSegment2D(startTip, endTip)); }