|
Imports System |
|
Imports System.Math |
|
Public Class PointDetermination |
|
Public Structure Point |
|
Public x, y As Double |
|
End Structure |
|
Public Structure Result |
|
Public x, y As Double |
|
Public m_x, m_y, m_p As Double |
|
End Structure |
|
Private ro As Double = 636.6197 |
|
Public Function intersection(ByVal pntA As Point, ByVal pntB As Point, _ |
|
ByVal b1 As Double, ByVal b2 As Double, _ |
|
ByVal mB As Integer) As Result |
|
Dim angle As Object = New Angle |
|
Dim sap, sbp, c As Double |
|
Dim b3, aap, abp, aab, aba As Double |
|
Dim pntP(2) As Point |
|
Dim res As Result |
|
If pntA.x = pntB.x And pntA.y = pntB.y Then |
|
Throw New Exception(String.Format(My.Resources.equivalentPoints, "A", "B")) |
|
End If |
|
If (b1 + b2) >= 200 Then |
|
Throw New Exception(My.Resources.invalidAngleValue) |
|
End If |
|
If b1 <= 0 Or b2 <= 0 Then |
|
Throw New Exception(My.Resources.invalidAngleValue) |
|
End If |
|
aab = angle.headingAngle(pntB.y - pntA.y, pntB.x - pntA.x) |
|
c = Sqrt(Math.Pow(pntB.y - pntA.y, 2) + Math.Pow(pntB.x - pntA.x, 2)) |
|
b3 = 200 - (b1 + b2) |
|
sap = (c * Sin(angle.toRad(b2))) / Sin(angle.toRad(b3)) |
|
sbp = (c * Sin(angle.toRad(b1))) / Sin(angle.toRad(b3)) |
|
aap = If(aab - b1 < 0, aab - b1 + 400, aab - b1) |
|
aba = If(aab < 200, aab + 200, aab - 200) |
|
abp = If(aba + b2 > 400, aba + b2 - 400, aba + b2) |
|
With pntP(0) |
|
.x = pntA.x + sap * Cos(angle.toRad(aap)) |
|
.y = pntA.y + sap * Sin(angle.toRad(aap)) |
|
End With |
|
With pntP(1) |
|
.x = pntB.x + sbp * Cos(angle.toRad(abp)) |
|
.y = pntB.y + sbp * Sin(angle.toRad(abp)) |
|
End With |
|
With res |
|
.x = (pntP(0).x + pntP(1).x) * 0.5 |
|
.y = (pntP(0).y + pntP(1).y) * 0.5 |
|
.m_x = Nothing |
|
.m_y = Nothing |
|
.m_p = (mB / (ro * Sin(angle.toRad(b3)))) * Sqrt(Math.Pow(sap, 2) + Math.Pow(sbp, 2)) |
|
End With |
|
Return res |
|
End Function |
|
Public Function arcSection(ByVal pntA As Point, ByVal pntB As Point, _ |
|
ByVal sap As Double, ByVal sbp As Double, _ |
|
ByVal a As Double, ByVal b As Double) As Result |
|
Dim angle As Object = New Angle |
|
Dim b1, b2, b3 As Double |
|
Dim aap, abp, aab, aba As Double |
|
Dim dx, dy, s, c As Double |
|
Dim m_s As Double |
|
Dim pntP(2) As Point |
|
Dim res As Result |
|
If pntA.x = pntB.x And pntA.y = pntB.y Then |
|
Throw New Exception(String.Format(My.Resources.equivalentPoints, "A", "B")) |
|
End If |
|
If sap <= 0 Or sbp <= 0 Then |
|
Throw New Exception(My.Resources.negativeOrZeroLengthSide) |
|
End If |
|
If (Sqrt(Math.Pow(pntA.x - pntB.x, 2) + Math.Pow(pntA.y - pntB.y, 2))) >= (sap + sbp) Then |
|
Throw New Exception(My.Resources.notAVerticesOfATriangle) |
|
End If |
|
If (Sqrt(Math.Pow(pntA.x - pntB.x, 2) + Math.Pow(pntA.y - pntB.y, 2)) + sap) <= sbp Then |
|
Throw New Exception(My.Resources.notAVerticesOfATriangle) |
|
End If |
|
If (Sqrt(Math.Pow(pntA.x - pntB.x, 2) + Math.Pow(pntA.y - pntB.y, 2)) + sbp) <= sap Then |
|
Throw New Exception(My.Resources.notAVerticesOfATriangle) |
|
End If |
|
dy = pntB.y - pntA.y |
|
dx = pntB.x - pntA.x |
|
aab = angle.headingAngle(dy, dx) |
|
c = Sqrt(Math.Pow(dy, 2) + Math.Pow(dx, 2)) |
|
s = 0.5 * (sap + sbp + c) |
|
b1 = 2 * angle.toGrad(Atan(Sqrt(((s - sap) * (s - c)) / (s * (s - sbp))))) |
|
b2 = 2 * angle.toGrad(Atan(Sqrt(((s - sbp) * (s - c)) / (s * (s - sap))))) |
|
b3 = 2 * angle.toGrad(Atan(Sqrt(((s - sap) * (s - sbp)) / (s * (s - c))))) |
|
aap = If(aab - b1 < 0, aab - b1 + 400, aab - b1) |
|
aba = If(aab < 200, aab + 200, aab - 200) |
|
abp = If(aba + b2 > 400, aba + b2 - 400, aba + b2) |
|
With pntP(0) |
|
.x = pntA.x + sap * Cos(angle.toRad(aap)) |
|
.y = pntA.y + sap * Sin(angle.toRad(aap)) |
|
End With |
|
With pntP(1) |
|
.x = pntB.x + sbp * Cos(angle.toRad(abp)) |
|
.y = pntB.y + sbp * Sin(angle.toRad(abp)) |
|
End With |
|
m_s = a + b * (((sap + sbp) * 0.001) * 0.5) |
|
With res |
|
.x = (pntP(0).x + pntP(1).x) * 0.5 |
|
.y = (pntP(0).y + pntP(1).y) * 0.5 |
|
.m_x = (m_s / Sin(angle.toRad(b3))) * Sqrt(Math.Pow(Sin(angle.toRad(aap)), 2) + Math.Pow(Sin(angle.toRad(abp)), 2)) |
|
.m_y = (m_s / Sin(angle.toRad(b3))) * Sqrt(Math.Pow(Cos(angle.toRad(aap)), 2) + Math.Pow(Cos(angle.toRad(abp)), 2)) |
|
.m_p = (m_s / Sin(angle.toRad(b3))) * Sqrt(2) |
|
End With |
|
Return res |
|
End Function |
|
End Class |