Public Function Dpp(P1, P2)
'oblicza odleglosc midzy 2 puntkami
If UBound(P1) = 2 And UBound(P2) = 2 Then
Dpp = Sqr((P2(0) - P1(0)) ^ 2# + (P2(1) - P1(1)) ^ 2# + (P2(2) - P1(2)) ^ 2#)
Else
Dpp = Sqr((P2(0) - P1(0)) ^ 2# + (P2(1) - P1(1)) ^ 2#)
End If
End Function
Public Function PLD(IP1, IP2, IDist)
'zwraca punkt (tablica współrzędnych) w określonej odległosci od 1 punktu w kierunku drugiego
distance = Dpp(IP1, IP2)
Dim TmpVec(2) As Double
If IDist = 0 Then
readyVec = IP1
Else
If distance > 0 Then
DispVec = Array(IP2(0) - IP1(0), IP2(1) - IP1(1), IP2(2) - IP1(2))
vecnor = Array(DispVec(0) / (distance / IDist), DispVec(1) / (distance / IDist), DispVec(2) / (distance / IDist))
readyVec = Array(IP1(0) + vecnor(0), IP1(1) + vecnor(1), IP1(2) + vecnor(2))
Else
readyVec = IP1
End If
End If
TmpVec(0) = readyVec(0): TmpVec(1) = readyVec(1): TmpVec(2) = readyVec(2)
PLD = TmpVec
End Function
Public Sub Krzyzyk()
Dim P1 As Variant
Dim P2 As Variant
P1 = ThisDocument.Utility.GetPoint(, "Wskaż punkt: ")
P2 = ThisDocument.Utility.GetPoint(P1, "Wskaż punkt: ")
Dim lineObj1 As ZwcadLine
Set lineObj1 = ThisDocument.ModelSpace.AddLine(P1, P2)
lineObj1.LineWeight = zcLnWt050
'lineObj1.Color = zcBlue
ThisDocument.Regen
Dim Px
Dim P3
Dim P4
Dim Odleglosc As Double
Dlugosc = Dpp(P1, P2) ' / 2#
Px = P1 'PLD(P1, P2, Dlugosc)
Dim Nachylenie As Double
Nachylenie = ThisDocument.Utility.AngleFromXAxis(P1, P2)
Dim Pi As Double
Pi = 1.570796
P3 = Px 'ThisDocument.Utility.PolarPoint(Px, Nachylenie - Pi, Dlugosc)
P4 = ThisDocument.Utility.PolarPoint(Px, Nachylenie + Pi, -Dlugosc)
Dim lineObj2 As ZwcadLine
Set lineObj2 = ThisDocument.ModelSpace.AddLine(P3, P4)
lineObj2.LineWeight = zcLnWt050
'lineObj2.Color = zcGreen
ThisDocument.Regen
'rysuje kąt prosty z równych odcinków z dołu do góry od P1 do P2 w prawo od P1 drugi odcinek
End Sub