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 kółko()
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)
ThisDocument.Regen
Dim Px
Dim Odleglosc As Double
Dlugosc = Dpp(P1, P2) / 2#
Px = PLD(P1, P2, Dlugosc)
Dim Nachylenie As Double
Nachylenie = ThisDocument.Utility.AngleFromXAxis(P1, P2)
Dim Pi As Double
Pi = 1.570796
Dim P3
P3 = ThisDocument.Utility.PolarPoint(P1, Nachylenie, Dlugosc)
Dim okrąg As ZwcadCircle
Set okrąg = ThisDocument.ModelSpace.AddCircle(P3, Dlugosc * 0.55)
Dim Kreskowanie As ZwcadHatch
Dim objList(0 To 0) As ZwcadEntity
Set Kreskowanie = ThisDocument.ModelSpace.AddHatch(zcHatchPatternTypePreDefined, "Solid", False)
Set objList(0) = okrąg
Kreskowanie.AppendOuterLoop objList
Dim Color
Set Color = Kreskowanie.TrueColor
Color.SetRGB 255, 0, 0
Kreskowanie.TrueColor = Color
Kreskowanie.Update
lineObj1.Delete
ThisDocument.Regen
End Sub
'wstawia kółko