AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

double in Schleife und Nachkommastellen

Ein Thema von ebi · begonnen am 7. Dez 2024 · letzter Beitrag vom 11. Dez 2024
 
ebi

Registriert seit: 8. Sep 2024
11 Beiträge
 
Delphi 12 Athens
 
#1

double in Schleife und Nachkommastellen

  Alt 7. Dez 2024, 17:24
hallo Zusammen,

weshalb kommen plötzlich so viele Nachkomma Zahlen?

Delphi-Quellcode:
procedure TFormStechen.berechnen();
var
  P1, P2, P5, P6: TKoordinate;
  P: TMittelpunkt;
  aussenDm, grundDm, process, ap, safety, returnX: double;
  X_inc: double;
  drehrichtung: string;
  Zaehler: integer;
begin
  Zaehler := 1;
  X_inc := 0;
  abbruch := false;
  try
    try
      aussenDm := StrToFloat(EditAussendurchmesser.Text);
      process := StrToFloat(Edit_process.Text);
      ap := StrToFloat(EditZustellung.Text);
      safety := StrToFloat(EditSicherheitsabstand.Text);
      returnX := StrToFloat(EditSicherheitsposition.Text);
      drehrichtung := ComboBoxDrehrichtung.Text;

      grundDm := FGrundDm;
      P1.X := aussenDm;
      P1.Z := FStartPkt;
      P2.X := FRadiusDm;
      P2.Z := FStartPkt;
      P5.X := FRadiusDm;
      P5.Z := FEndPkt;
      P6.X := aussenDm;
      P6.Z := FEndPkt;

      X_pos := P1.X;
      Z_pos := P1.Z;

      if (FormMain.RichEditMain.Lines.Count <> 0) then
        NC_program(Format('M%d'#13#10, [1]));

      NC_program(Format('(Stechdrehen: %s)', [FormatDateTime('yy-mm-dd hh:nn:ss am/pm', Now())]));
      NC_program(Format('G0 X%g', [returnX]));
      NC_program(Format('G0 Z%g', [Z_pos]));
      NC_program(Format('G0 X%g', [X_pos + safety]));

      if (Z_pos = P2.Z) then
        Z_pos := P5.Z
      else
        Z_pos := P2.Z;

      NC_program(Format('G1 X%g', [X_pos]));
      NC_program(Format('G1 Z%g', [Z_pos]));

      FormMain.SubProcessBar(FormMain.ProgressBarMain, true, Floor(FEinstichtiefe / ap));

      repeat
        X_pos := X_pos - ap;
        if (X_pos < P2.X) then
          X_pos := P2.X;

        if (Z_pos = P2.Z) then
          Z_pos := P5.Z
        else
          Z_pos := P2.Z;

        NC_program(Format('G1 X%g', [X_pos]));
        NC_program(Format('G1 Z%g', [Z_pos]));

        if ((Zaehler * ap) > process) then
          begin
            Zaehler := 1;
            abfahren(safety);
            NC_program(Format('G0 X%g', [returnX]));
            NC_program(Format('M%d', [1]));
            anfahren(safety);
          end
        else
          Zaehler := Zaehler + 1;

        if (abbruch) then
          exit;

        FormMain.Prozess();
      until not(RoundTo(X_pos, -3) > RoundTo(P2.X, -3));

      P.mpX := X_pos;

      repeat
        P.mpX := P.mpX - ap;
        X_inc := X_inc + ap;
        if (P.mpX < grundDm) then
          begin
            P.mpX := grundDm;
            X_inc := X_pos - grundDm;
          end;

        if (Z_pos = P2.Z) then
          begin
            P.mpZ := Z_pos - X_inc / 2;
            P.mpI := 0;
            P.mpK := (X_inc / 2) * (-1);
            NC_program(Format('G2 X%g Z%g I%g K%g', [P.mpX, P.mpZ, P.mpI, P.mpK]));
            P.mpZ := P5.Z + (X_inc / 2);
            NC_program(Format('G1 Z%g', [P.mpZ]));
            P.mpZ := P5.Z;
            P.mpI := X_inc / 2;
            P.mpK := 0;
            NC_program(Format('G2 X%g Z%g I%g K%g', [X_pos, P.mpZ, P.mpI, P.mpK]));
            Z_pos := P5.Z;
          end
        else
          begin
            P.mpZ := Z_pos + X_inc / 2;
            P.mpI := 0;
            P.mpK := X_inc / 2;
            NC_program(Format('G3 X%g Z%g I%g K%g', [P.mpX, P.mpZ, P.mpI, P.mpK]));
            P.mpZ := P2.Z - (X_inc / 2);
            NC_program(Format('G1 Z%g', [P.mpZ]));
            P.mpZ := P2.Z;
            P.mpI := X_inc / 2;
            P.mpK := 0;
            NC_program(Format('G3 X%g Z%g I%g K%g', [X_pos, P.mpZ, P.mpI, P.mpK]));
            Z_pos := P2.Z;
          end;

        if (abbruch) then
          exit;

        FormMain.Prozess();
      until not(RoundTo(P.mpX, -3) > RoundTo(grundDm, -3));

      abfahren(safety);
      NC_program(Format('G0 X%g', [returnX]));
    except
      on e: EConvertError do
        ShowMessage(e.Message);
    end;
  finally
    FormMain.SubProcessBar(FormMain.ProgressBarMain, false, 0);
    abbruch := true;
  end;
end;
Angehängte Grafiken
Dateityp: png Screenshot 2024-12-07 171938.png (112,4 KB, 50x aufgerufen)
  Mit Zitat antworten Zitat
 


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 00:16 Uhr.
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz