private void DrawZDistributedLoad(DistributedLoad load) { for (int i = 0; i < Math.Floor((load.EndLocation - load.StartLocation) / 20) + 1; i++) { var circle = new Ellipse() { Height = 6, Width = 6, Fill = Brushes.DarkViolet, Stroke = Brushes.DarkViolet }; Canvas.SetTop(circle, 247); Canvas.SetLeft(circle, load.StartLocation + i * 20); _canvas.Children.Add(circle); DrawText(load.StartLocation, 230, load.StartMagnitude + "k/ft", Color.FromRgb(148, 0, 211)); DrawText(load.EndLocation, 230, load.EndMagnitude + "k/ft", Color.FromRgb(148, 0, 211)); } }
private void DrawMxDistributedLoad(DistributedLoad load) { for (int i = 0; i < Math.Floor((load.EndLocation - load.StartLocation) / 10) + 1; i++) { var newx = load.StartLocation + i * 10; var line = new Line { X1 = newx, X2 = newx, Y1 = 230, Y2 = 270, Stroke = Brushes.DarkViolet, StrokeThickness = 1 }; _canvas.Children.Add(line); DrawText(load.StartLocation, 210, load.StartMagnitude + "k-ft/ft", Color.FromRgb(148, 0, 211)); DrawText(load.EndLocation, 210, load.EndMagnitude + "k-ft/ft", Color.FromRgb(148, 0, 211)); } }
private void DrawSXDistributedLoad(DistributedLoad load) { for (int i = 0; i < Math.Floor((load.EndLocation - load.StartLocation) / 20) + 1; i++) { var newx = load.StartLocation + i * 20; var arrow = new Polyline() { Points = new PointCollection { new Point(newx, 245), new Point(newx + 10, 250), new Point(newx, 255), }, Fill = Brushes.DarkGreen, }; _canvas.Children.Add(arrow); DrawText(load.StartLocation, 230, load.StartMagnitude + "kfs", Color.FromRgb(0, 100, 0)); DrawText(load.EndLocation, 230, load.EndMagnitude + "kfs", Color.FromRgb(0, 100, 0)); } }
private void DrawXDistributedLoad(DistributedLoad load) { double scaleY = 0.8, scaleX = 2.0; double smag = load.StartMagnitude; double arrownum = Math.Floor((load.EndLocation - load.StartLocation) / 20) + 1; double step = (load.EndMagnitude - load.StartMagnitude) / arrownum; var direction = load.StartMagnitude >= 0 && load.EndMagnitude >= 0; for (int i = 0; i < arrownum; i++) { var newx = load.StartLocation + i * 20; var uparrow = new Line { X1 = newx, X2 = direction ? newx - scaleX * smag - 5 : newx + scaleX * -smag + 5, Y1 = 250, Y2 = scaleY * (smag > 0 ? -smag : smag) + 248, Stroke = Brushes.DarkViolet, StrokeThickness = 1, }; var downarrow = new Line { X1 = newx, X2 = direction ? newx - scaleX * smag - 5 : newx + scaleX * -smag + 5, Y1 = 250, Y2 = -scaleY * (smag > 0 ? -smag : smag) + 252, Stroke = Brushes.DarkViolet, StrokeThickness = 1, }; smag += step; _canvas.Children.Add(uparrow); _canvas.Children.Add(downarrow); DrawText(load.StartLocation - 20, 220, load.StartMagnitude + " k/ft", Color.FromRgb(148, 0, 211)); DrawText(load.EndLocation, 220, load.EndMagnitude + " k/ft", Color.FromRgb(148, 0, 211)); } }
private double GetAngle(DistributedLoad load) { return(Math.Atan((load.EndMagnitude - load.StartMagnitude) / (load.StartLocation - load.EndLocation)) * 180 / Math.PI); }
private double Line(double x, DistributedLoad load) { return(((x - load.StartLocation) * (load.EndMagnitude - load.StartMagnitude)) / (load.EndLocation - load.StartLocation) + load.StartMagnitude); }
private void DrawYDistributedLoad(DistributedLoad load) { var color = Brushes.DarkViolet; var units = "k/ft"; if (load.Direction == LoadDirection.T) { units = "F"; } if (load.Direction == LoadDirection.SY || load.Direction == LoadDirection.Sy) { units = "ksf"; color = Brushes.DarkGreen; } var lineload = new Line { X1 = load.StartLocation, X2 = load.EndLocation, Y1 = 250 + load.StartMagnitude, Y2 = 250 + load.EndMagnitude, Stroke = color, StrokeThickness = 2 }; _canvas.Children.Add(lineload); for (int i = 0; i < Math.Floor((load.EndLocation - load.StartLocation) / 20) + 1; i++) { double scaleY = 20, scaleX = 10, angle, maxload; var newx = load.StartLocation + i * 20; angle = GetAngle(load); maxload = Math.Abs(load.StartMagnitude) > Math.Abs(load.EndMagnitude) ? load.StartMagnitude : -load.EndMagnitude; if (angle < 0 && (250 - Line(newx, load)) > 250) { scaleY = 20 * (Line(newx, load) / maxload); scaleX = 10 * (Line(newx, load) / maxload); } if (angle < 0 && (250 - Line(newx, load)) < 250) { scaleY = -20 * ((Line(newx, load) / maxload)); scaleX = -10 * ((Line(newx, load) / maxload)); } if (angle > 0 && (250 - Line(newx, load)) < 250) { scaleY = 20 * ((Line(newx, load) / maxload)); scaleX = 10 * ((Line(newx, load) / maxload)); } if (angle > 0 && (250 - Line(newx, load)) > 250) { scaleY = -20 * ((Line(newx, load) / maxload)); scaleX = -10 * ((Line(newx, load) / maxload)); } var line = new Line { X1 = newx, X2 = newx, Y1 = 250, Y2 = 250 + Line(newx, load), Stroke = color, StrokeThickness = 1 }; var larrow = new Line { X1 = newx, X2 = newx - scaleX, Y1 = 250, Y2 = (250 - Line(newx, load)) > 250 ? (250 - scaleY) : (250 + scaleY), Stroke = color, StrokeThickness = 1 }; var rarrow = new Line { X1 = newx, X2 = newx + scaleX, Y1 = 250, Y2 = (250 - Line(newx, load)) > 250 ? (250 - scaleY) : (250 + scaleY), Stroke = color, StrokeThickness = 1 }; _canvas.Children.Add(line); _canvas.Children.Add(larrow); _canvas.Children.Add(rarrow); } DrawText(load.StartLocation - 45, 250 + load.StartMagnitude, load.StartMagnitude + units, Color.FromRgb(0, 0, 0)); DrawText(load.EndLocation + 10, 250 + load.EndMagnitude - 10, load.EndMagnitude + units, Color.FromRgb(0, 0, 0)); DrawText(100, 100, GetAngle(load).ToString(), Color.FromRgb(0, 0, 0)); }