Autor Beitrag
Hasche
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Do 10.01.08 12:00 
Hey!

Versuche ein Programm zu erstellen, wo mir das Programm die Länge zwischen 2 bestimmten Punkten sagen soll.
Es ist ein Punkt festgelegt (Lösung) und einer soll vom Benutzer eingegeben werden.
Der Abstand zwischen diesen Punkten soll dann ausgegeben werden.
Ist das iwie programmierbar? :)

Danke für eure Hilfe!
Blackheart666
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2195

XP
D3Prof, D6Pers.
BeitragVerfasst: Do 10.01.08 12:05 
Cursorpositionen merken und Diverenz ausrechnen.

_________________
Blackheart666
Der Irrsinn ist bei Einzelnen etwas Seltenes, - aber bei Gruppen, Parteien, Völkern, Zeiten die Regel. (Friedrich Nietzsche)
Hasche Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Do 10.01.08 12:09 
Hastu zufällig grade den Code zur Hand bzw könntest ihn mir schreiben, bin Anfänger und weiß nich, wie ich das nun anfangen soll.
Aber dass es geht, ist ja schonma schön zu hören :)
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 10.01.08 12:10 
Ja, das ist machbar. Als Formel dürfte der Satz von Pythagoras dienen. Die Entfernung zweier Punkte ist danach die Wurzel aus der Summe der Quadrate der Differenzen der Koordinaten. Also

ausblenden Delphi-Quelltext
1:
Abstand := sqrt( sqr(x1 - x2) + sqr(y1 - y2) );					

_________________
We are, we were and will not be.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 10.01.08 12:30 
Kleine Verbesserung für die Formel:
ausblenden Delphi-Quelltext
1:
Abstand := sqrt( sqr(abs(x1 - x2)) + sqr(abs(y1 - y2)) );					

Sonst besteht die Gefahr, dass das Argument der Wurzel negativ ist. Das ist dann nicht so hübsch. :wink:
Hasche Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 43



BeitragVerfasst: Do 10.01.08 12:33 
Wie kann ich Delphi sagen, dass bei einem Mausklick auf zB ein Bild ein Kreis erscheint?

Danke
Gausi
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 8554
Erhaltene Danke: 481

Windows 7, Windows 10
D7 PE, Delphi XE3 Prof, Delphi 10.3 CE
BeitragVerfasst: Do 10.01.08 12:38 
Neue Frage, neues Topic, bitte ;-)

@Peter: sqr ist das Quadrat, nicht die Wurzel. Minus mal Minus gibt Plus und Plus plus Plus ist Plus (von einem Überlauf mal abgesehen). Somit ist auch ohne abs das Ding unter der Wurzel immer positiv. ;-)

_________________
We are, we were and will not be.
jasocul
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 6395
Erhaltene Danke: 149

Windows 7 + Windows 10
Sydney Prof + CE
BeitragVerfasst: Do 10.01.08 12:51 
Ist mir gerade beim Mittagessen auch eingefallen, dass das Blödsinn ist. :autsch: