好吧,我还带着另一个大脑破坏者:)
我需要在两次射击之间画一条线,这是最大传播。
我正在使用下面的代码,但是它绘制了矩形角之间的线条。我知道这是错的,但不知道如何使用此代码找到点。
我很长时间地更新了代码(所以我的大脑可以包裹它)。
基本上是" L"变量将测试为最长的。然后,我需要抓住相应的点,并且#34; L"变量
Private Sub DrawMaxCTCLine(g As Graphics)
Dim minx, miny, maxx, maxy As Integer
Dim P1, P2, P3, P4 As Point
Dim L1, L2, L3, L4, L5, L6 As Decimal
maxx = shotList.Max(Function(point) point.X)
maxy = shotList.Max(Function(point) point.Y)
minx = shotList.Min(Function(point) point.X)
miny = shotList.Min(Function(point) point.Y)
P1 = shotList.Find(Function(point) point.X = maxx)
P2 = shotList.Find(Function(point) point.Y = maxy)
P3 = shotList.Find(Function(point) point.X = minx)
P4 = shotList.Find(Function(point) point.Y = miny)
L1 = Math.Sqrt((P1.X - P2.X) ^ 2 + (P1.Y - P2.Y) ^ 2)
L2 = Math.Sqrt((P1.X - P3.X) ^ 2 + (P1.Y - P3.Y) ^ 2)
L3 = Math.Sqrt((P1.X - P4.X) ^ 2 + (P1.Y - P4.Y) ^ 2)
L4 = Math.Sqrt((P2.X - P3.X) ^ 2 + (P2.Y - P3.Y) ^ 2)
L5 = Math.Sqrt((P2.X - P4.X) ^ 2 + (P2.Y - P4.Y) ^ 2)
L6 = Math.Sqrt((P3.X - P4.X) ^ 2 + (P3.Y - P4.Y) ^ 2)
这是我正在讨论的线条的更好图像(突出显示)
答案 0 :(得分:0)
这就是我如何让它发挥作用的漫长道路。打开任何更简洁的东西。
Private Sub DrawMaxCTCLine(g As Graphics)
Dim minx, miny, maxx, maxy As Integer
Dim P1, P2, P3, P4 As Point
Dim L1, L2, L3, L4, L5, L6 As Decimal
Dim maxSpread As Decimal = 0
maxx = shotList.Max(Function(point) point.X)
maxy = shotList.Max(Function(point) point.Y)
minx = shotList.Min(Function(point) point.X)
miny = shotList.Min(Function(point) point.Y)
P1 = shotList.Find(Function(point) point.X = maxx)
P2 = shotList.Find(Function(point) point.Y = maxy)
P3 = shotList.Find(Function(point) point.X = minx)
P4 = shotList.Find(Function(point) point.Y = miny)
L1 = Math.Sqrt((P1.X - P2.X) ^ 2 + (P1.Y - P2.Y) ^ 2)
L2 = Math.Sqrt((P1.X - P3.X) ^ 2 + (P1.Y - P3.Y) ^ 2)
L3 = Math.Sqrt((P1.X - P4.X) ^ 2 + (P1.Y - P4.Y) ^ 2)
L4 = Math.Sqrt((P2.X - P3.X) ^ 2 + (P2.Y - P3.Y) ^ 2)
L5 = Math.Sqrt((P2.X - P4.X) ^ 2 + (P2.Y - P4.Y) ^ 2)
L6 = Math.Sqrt((P3.X - P4.X) ^ 2 + (P3.Y - P4.Y) ^ 2)
Dim lList As New List(Of Decimal)
lList.Add(L1)
lList.Add(L2)
lList.Add(L3)
lList.Add(L4)
lList.Add(L5)
lList.Add(L6)
maxSpread = lList.Max()
Dim pn As New Pen(My.Settings.Max_Spread_Line, 1)
Dim Dash As Single() = {2, 5, 2, 5}
pn.DashPattern = Dash
Select Case maxSpread
Case L1
g.DrawLine(pn, P1, P2)
Case L2
g.DrawLine(pn, P1, P3)
Case L3
g.DrawLine(pn, P1, P4)
Case L4
g.DrawLine(pn, P2, P3)
Case L5
g.DrawLine(pn, P2, P4)
Case L6
g.DrawLine(pn, P3, P4)
End Select
pn.Dispose()
lList.Clear()
Console.WriteLine("P1" & P1.ToString & vbCrLf & "P2" & P2.ToString & vbCrLf & "P3" & P3.ToString & vbCrLf & "P4" & P4.ToString)
Console.WriteLine(L1.ToString & vbCrLf & L2.ToString & vbCrLf & L3.ToString & vbCrLf & L4.ToString & vbCrLf & L5.ToString & vbCrLf & L6.ToString)
Console.WriteLine(maxSpread)
End Sub