Autor Beitrag
Arbengie
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 66



BeitragVerfasst: Do 03.02.11 16:29 
Hi ic bin dabei eine Analoguhr in Delphi zu machen mit TCanvas doch bei der Berechnung der Sekundenzeigerposition hören meine Mathekenntnisse auf :?.

Habe das hier benutze, doch da kommen total komische Zeigepostiotionen raus.
www.bergt.de/worksho.../html/loesung311.htm

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
procedure TfrmMain.tmrTimeTimer(Sender: TObject);
var
  wSek, x, y, r: integer;
begin
  s := FormatDateTime('ss', Time);
  edtTime.Text := s;
  r := 50// Radius
  wSek := trunc(StrToInt(s) * (((2 * pi) / 60)) - pi / 2);
  x := Trunc(Cos(wSek)* r);
  y := Trunc(Sin(wSek)* r);
  x := x + (Width div 2);
  y := y + (Height div 2);
  newHaus.showClock(frmMain, x, y);
end;

procedure THaus.showClock(kContainer: TForm; x, y: integer);
begin
  kContainer.Canvas.MoveTo(zX + (zVar * 2) + (zVar div 2), zY - zVar + (zVar div 4));
  kContainer.Canvas.LineTo(x, y);
end;



Moderiert von user profile iconNarses: Topic aus Delphi Language (Object-Pascal) / CLX verschoben am Do 03.02.2011 um 15:30
Crombo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 54
Erhaltene Danke: 8

Windows 7, Windows Vista, Windows XP
Delphi XE Architect, Visual Studio 2010 Professional
BeitragVerfasst: Do 03.02.11 17:08 
Hallo,

Ein Kreis hat 360 Grad, eine Minute 60 Sekunden --> Jede Sekunde wird der Sekundenzeiger um 6 Grad im Uhrzeigersinn verschoben. Mal dir das am besten mal auf ein Blatt Papier und überleg dir, wie du die Zeigerposition von Hand berechnen würdest. Das Übertragen in Programmiersprache dauert dann gerade noch ne Minute.

Crombo

_________________
one day your life will flash before your eyes. make sure it's worth watching
FinnO
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1331
Erhaltene Danke: 123

Mac OSX, Arch
TypeScript (Webstorm), Kotlin, Clojure (IDEA), Golang (VSCode)
BeitragVerfasst: Do 03.02.11 17:10 
Moin,

wenn du aber der Meinung bist, deine mathematischen Kenntnisse versagten, schau dir doch Sinus und Kosinus einmal an.
Arbengie Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 66



BeitragVerfasst: Do 03.02.11 18:48 
ich check das mit sinus cosinus usw nich -.-
Gerd Kayser
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 632
Erhaltene Danke: 121

Win 7 32-bit
Delphi 2006/XE
BeitragVerfasst: Do 03.02.11 20:23 
user profile iconArbengie hat folgendes geschrieben Zum zitierten Posting springen:
Hi ic bin dabei eine Analoguhr in Delphi zu machen mit TCanvas doch bei der Berechnung der Sekundenzeigerposition hören meine Mathekenntnisse auf
Schau Dir das einmal an: delphiforfun.org/programs/clock_angle.htm
Da findest Du eine Demo und die Sourcen.
F34r0fTh3D4rk
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 5284
Erhaltene Danke: 27

Win Vista (32), Win 7 (64)
Eclipse, SciTE, Lazarus
BeitragVerfasst: Do 03.02.11 20:37 
Ich empfehle einen Blick auf diese Grafik: upload.wikimedia.org...rigEinheitskreis.png
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 03.02.11 21:50