AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Programmierung allgemein Programmieren allgemein Ellipsenalgo aus Formelsammlung kreieren
Thema durchsuchen
Ansicht
Themen-Optionen

Ellipsenalgo aus Formelsammlung kreieren

Ein Thema von delphifan2004 · begonnen am 8. Jul 2025 · letzter Beitrag vom 12. Jul 2025
 
Michael II

Registriert seit: 1. Dez 2012
Ort: CH BE Eriswil
778 Beiträge
 
Delphi 11 Alexandria
 
#14

AW: Ellipsenalgo aus Formelsammlung kreieren

  Alt 11. Jul 2025, 00:27
Für Rastergrafik: Midpoint Algorithmus für Kreis und Ellipse

https://www.geeksforgeeks.org/dsa/mi...ing-algorithm/

(könnte man erweitern (stangle,endangle))

Delphi-Quellcode:
procedure DrawEllipseMidpoint(xc, yc, rx, ry: Integer);
var
  x, y: Int64;
  rx2, ry2: Int64;
  twoRx2, twoRy2: Int64;
  px, py: Int64;
  p: Int64;
begin
  x := 0;
  y := ry;

  rx2 := rx * rx;
  ry2 := ry * ry;
  twoRx2 := 2 * rx2;
  twoRy2 := 2 * ry2;

  // Region 1
  p := Round(ry2 - (rx2 * ry) + (0.25 * rx2));
  px := 0;
  py := twoRx2 * y;

  while px < py do
  begin
    // 4-fache Symmetrie
    DrawPixel(xc + x, yc + y);
    DrawPixel(xc - x, yc + y);
    DrawPixel(xc + x, yc - y);
    DrawPixel(xc - x, yc - y);

    Inc(x);
    px := px + twoRy2;

    if p < 0 then
      p := p + ry2 + px
    else
    begin
      Dec(y);
      py := py - twoRx2;
      p := p + ry2 + px - py;
    end;
  end;

  // Region 2
  p := Round(ry2 * (x + 0.5) * (x + 0.5) + rx2 * (y - 1) * (y - 1) - rx2 * ry2);
  px := twoRy2 * x;
  py := twoRx2 * y;

  while y >= 0 do
  begin
    // 4-fache Symmetrie
    DrawPixel(xc + x, yc + y);
    DrawPixel(xc - x, yc + y);
    DrawPixel(xc + x, yc - y);
    DrawPixel(xc - x, yc - y);

    Dec(y);
    py := py - twoRx2;

    if p > 0 then
      p := p + rx2 - py
    else
    begin
      Inc(x);
      px := px + twoRy2;
      p := p + rx2 - py + px;
    end;
  end;
end;
Michael Gasser
  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 14:56 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-2025 by Thomas Breitkreuz