;<AutoItScript>
#NoTrayIcon ;ohne SysTray-Icon, hängende Prozesse mit TaskMan beenden
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
Opt('MustDeclareVars', 0) ;0=ohne, 1=erfordert Variablen-Deklaration
;+----------------------------------------------------------------+
;| AnzeigeCheck: |Il1 sind Alt-0124, GROßES i, kleines L, Eins |
;| Sonderzeichen: „ä”öüáߎę֚Üñ±ø°¸© |
;| Header: Bestimmung der Parameter (alle sind Strings!!!) |
Const $Author='k3p.au3 ©2012 by ytwinky, MD'; |
;| EMail: PIII1kSystem-AutoIt3Forum@yahoo.de |
;| AutoIt3-Version: 3.3.8.1, Beta: 3.3.9.4 |
;| Editor: SciTE 3.2.0d, fixed font |
;| Zweck : Kreisberechnung durch 3 Punkte |
;| setze Tab auf 2 für Lesbarkeit |
;+----------------------------------------------------------------+
Global $Pkt[4][3], $s=0
#Region ### START Koda GUI section ### Form=D:\Sprachen\AutoIt3\Au3\kxf\K3P.kxf
$K3P=GUICreate('K3P', 496, 328, 252, 122)
$grpMain=GUICtrlCreateGroup('', 0, -6, 495, 333)
GUICtrlCreateLabel('Kreis durch 3 Punkte', 4, 6, 244, 33)
GUICtrlSetFont(-1, 18, 800, 0, 'Arial')
GUICtrlSetColor(-1, 0x000080)
GUICtrlSetTip(-1, $Author)
$grpEingabe=GUICtrlCreateGroup('Eingabe', 4, 36, 487, 157)
$grpLinks=GUICtrlCreateGroup('linker Punkt', 7, 101, 157, 87)
GUICtrlCreateLabel('Bezeichnung', 12, 121, 66, 17)
$ezPNr1=GUICtrlCreateInput('P1', 78, 118, 81, 21)
GUICtrlCreateLabel('Rechtwert', 11, 143, 53, 17)
$ezyp1=GUICtrlCreateInput('0.9080732', 78, 141, 81, 21)
GUICtrlCreateLabel('Hochwert', 11, 166, 50, 17)
$ezxp1=GUICtrlCreateInput('4.0642982', 78, 163, 81, 21)
GUICtrlCreateGroup('', -99, -99, 1, 1)
$grpMitte=GUICtrlCreateGroup('mittlerer Punkt', 169, 48, 157, 87)
GUICtrlCreateLabel('Bezeichnung', 174, 68, 66, 17)
$ezPNr2=GUICtrlCreateInput('P2', 240, 65, 81, 21)
GUICtrlCreateLabel('Rechtwert', 173, 91, 53, 17)
$ezyp2=GUICtrlCreateInput('2.8485684', 240, 88, 81, 21)
GUICtrlCreateLabel('Hochwert', 173, 113, 50, 17)
$ezxp2=GUICtrlCreateInput('1.6679862', 240, 110, 81, 21)
GUICtrlCreateGroup('', -99, -99, 1, 1)
$Group4=GUICtrlCreateGroup('rechter Punkt', 331, 101, 157, 87)
GUICtrlCreateLabel('Bezeichnung', 336, 121, 66, 17)
$ezPNr3=GUICtrlCreateInput('P3', 402, 118, 81, 21)
GUICtrlCreateLabel('Rechtwert', 335, 144, 53, 17)
$ezyp3=GUICtrlCreateInput('0.4589868', 402, 141, 81, 21)
GUICtrlCreateLabel('Hochwert', 335, 166, 50, 17)
$ezxp3=GUICtrlCreateInput('4.0996421', 402, 163, 81, 21)
GUICtrlCreateGroup('', -99, -99, 1, 1)
$btnBerechnen=GUICtrlCreateButton('Berechnen', 210, 154, 75, 25)
GUICtrlSetFont(-1, 8, 800, 0, 'MS Sans Serif')
GUICtrlCreateGroup('', -99, -99, 1, 1)
$Berechnung=GUICtrlCreateGroup('Berechnung', 4, 194, 487, 129)
$grpBerechnung=GUICtrlCreateGroup('Zentrum', 9, 211, 157, 107)
GUICtrlCreateLabel('Rechtwert', 13, 230, 53, 17)
$ezyZ=GUICtrlCreateInput('ezyZ', 66, 227, 81, 21)
GUICtrlCreateLabel('Hochwert', 13, 252, 50, 17)
$ezxZ=GUICtrlCreateInput('ezxZ', 66, 249, 81, 21)
GUICtrlCreateLabel('Radius', 15, 296, 37, 17)
$ezRadius=GUICtrlCreateInput('Radius', 66, 293, 81, 21)
GUICtrlCreateGroup('', -99, -99, 1, 1)
$grpKontrolle=GUICtrlCreateGroup('Konrollrechnung', 168, 211, 319, 107)
GUICtrlCreateLabel('Strecke vom Zentrum zum', 172, 229, 128, 17)
GUICtrlCreateLabel('Differenz', 390, 229, 46, 17)
GUICtrlCreateLabel('linken Punkt', 230, 250, 63, 17)
$ezR1=GUICtrlCreateInput('ezR1', 307, 247, 81, 21)
$ezK1=GUICtrlCreateInput('ezK1', 390, 247, 81, 21)
GUICtrlCreateLabel('mittleren Punkt', 230, 272, 74, 17)
$ezR2=GUICtrlCreateInput('ezR2', 307, 269, 81, 21)
$ezK2=GUICtrlCreateInput('ezK2', 390, 269, 81, 21)
GUICtrlCreateLabel('rechten Punkt', 231, 294, 71, 17)
$ezR3=GUICtrlCreateInput('ezR3', 307, 291, 81, 21)
$ezK3=GUICtrlCreateInput('ezK3', 390, 291, 81, 21)
GUICtrlCreateGroup('', -99, -99, 1, 1)
GUICtrlCreateGroup('', -99, -99, 1, 1)
GUICtrlCreateGroup('', -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
Exit
Case $btnBerechnen
$Pkt[1][0]=GUICtrlRead($ezPNr1)
$Pkt[1][1]=GUICtrlRead($ezyp1)
$Pkt[1][2]=GUICtrlRead($ezxp1)
$Pkt[2][0]=GUICtrlRead($ezPNr2)
$Pkt[2][1]=GUICtrlRead($ezyp2)
$Pkt[2][2]=GUICtrlRead($ezxp2)
$Pkt[3][0]=GUICtrlRead($ezPNr3)
$Pkt[3][1]=GUICtrlRead($ezyp3)
$Pkt[3][2]=GUICtrlRead($ezxp3)
GUICtrlSetData($ezRadius, StringFormat('%3.11f', K3Pa()))
GUICtrlSetData($ezyZ, StringFormat('%3.11f', $Pkt[0][1]))
GUICtrlSetData($ezxZ, StringFormat('%3.11f', $Pkt[0][2]))
GUICtrlSetData($ezR1, StringFormat('%3.11f', Strecke(0, 1)))
GUICtrlSetData($ezR2, StringFormat('%3.11f', Strecke(0, 2)))
GUICtrlSetData($ezR3, StringFormat('%3.11f', Strecke(0, 3)))
GUICtrlSetData($ezK1, StringFormat('%3.3e', Strecke(0, 1)-GUICtrlRead($ezRadius)))
GUICtrlSetData($ezK2, StringFormat('%3.3e', Strecke(0, 2)-GUICtrlRead($ezRadius)))
GUICtrlSetData($ezK3, StringFormat('%3.3e', Strecke(0, 3)-GUICtrlRead($ezRadius)))
EndSwitch
WEnd
;<AutoItFunctions>
Func Strecke($PA, $PE)
Return Sqrt(($Pkt[$PA][1]-$Pkt[$PE][1])^2+($Pkt[$PA][2]-$Pkt[$PE][2])^2)
EndFunc
Func Mittel($a, $b)
Return ($a+$b)/2.0
EndFunc
Func K3Pa()
Local $y1s, $x1s, $y2s, $x2s, $m1=0, $m2=0, $i
;Koordinaten von P1'
$y1s=Mittel($Pkt[1][1], $Pkt[2][1])
$x1s=Mittel($Pkt[1][2], $Pkt[2][2])
;Koordinaten von P2'
$y2s=Mittel($Pkt[2][1], $Pkt[3][1])
$x2s=Mittel($Pkt[2][2], $Pkt[3][2])
;Steigungen berechnen
$dx21=$Pkt[2][2]-$Pkt[1][2]
$dx32=$Pkt[3][2]-$Pkt[2][2]
$m1=($Pkt[2][1]-$Pkt[1][1])/$dx21
$m2=($Pkt[3][1]-$Pkt[2][1])/$dx32
;1. Lösung, falls weder x2-x1=0 noch x3-x2=0 ist:
If $dx21*$dx32<>0 Then ;also sind beide<>0 !!
$xm1=$x1s+$m1*($m2*($y1s-$y2s)+($x1s-$x2s))/($m2-$m1)
$ym1=$y1s-($xm1-$x1s)/$m1
;Kontrolle:
$xm2=$x2s+$m2*($m1*($y1s-$y2s)+($x1s-$x2s))/($m2-$m1)
$ym2=$y2s-($xm2-$x2s)/$m2
$Pkt[0][1]=Mittel($ym1, $ym2)
$Pkt[0][2]=Mittel($xm1, $xm2)
ElseIf $dx21=0 Then ;2. Lösung, falls x2-x1=0 ist:
$Pkt[0][2]=$x2s-$m2*($y1s-$y2s)
$Pkt[0][1]=$y1s
ElseIf $dx32=0 Then ;3. Lösung, falls, x3-x2=0 ist:
$Pkt[0][2]=$x1s-$m1*($y2s-$y1s)
$Pkt[0][1]=$y2s
Else
$Pkt[0][1]='n.v.'
$Pkt[0][2]='n.v.'
$Pkt[0][0]='Keine Lösung'
Return 0
EndIf
$m1=0.0
$m2=0.0
For $i=1 To 3
$y1s=Abs($Pkt[0][1]-$Pkt[$i][1])*Abs($Pkt[0][2]-$Pkt[$i][2])
$m1+=$y1s
$m2+=Strecke(0, $i)*$y1s
Next
$Pkt[0][0]='Zentrum'
Return $m2/$m1 ;Radius zurückgeben..
EndFunc
;</AutoItScript>