1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154:
| unit MBaum01;
interface
uses UConfig, Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, Math;
type TForm1 = class(TForm) Image1: TImage; Paint: TButton; procedure FormCreate(Sender: TObject); private Auswahl: Integer; zaehler: Integer; OldAlpha: Double; Ast,i,j,row: Integer; a,b,c,c1, alpha, beta, gamma: Double; procedure PaintTree_Dreieck(XPoint1,YPoint1,XPoint2,YPoint2: Integer); procedure PaintTree_Viereck(XPoint1,YPoint1,XPoint2,YPoint2: Integer); procedure PaintTree_NewViereck(XPoint1,YPoint1,XPoint2,YPoint2: Integer); public SeitenLaenge: array [1..QUADRATE] of array [0..5] of Double; Old_alpha : array [1..QUADRATE] of array [0..5] of Double; X_Point1 : array [1..QUADRATE] of array [0..5] of Integer; Y_Point1 : array [1..QUADRATE] of array [0..5] of Integer; X_Point2 : array [1..QUADRATE] of array [0..5] of Integer; Y_Point2 : array [1..QUADRATE] of array [0..5] of Integer; end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject); begin // ShowMessage(FloatToStr(power(2,12))); Image1.Width := IMGWIDTH; Image1.Height := IMGHEIGHT; Form1.Width := IMGWIDTH + 10; Form1.Height := IMGHEIGHT + 60; Paint.Top := IMGHEIGHT + 4; Paint.Left := 0; Image1.Canvas.Rectangle(IMGWIDTH div 2 - VIERECK div 2, IMGHEIGHT - VIERECK, IMGWIDTH div 2 + VIERECK div 2, IMGHEIGHT); c := VIERECK; i := 0; j := 1; row := 0; Auswahl := 1; zaehler := 0; Ast := Tiefe; PaintTree_Dreieck(IMGWIDTH div 2 - VIERECK div 2,IMGHEIGHT - VIERECK, IMGWIDTH div 2 + VIERECK div 2,IMGHEIGHT - VIERECK); end;
procedure TForm1.PaintTree_Dreieck(XPoint1,YPoint1,XPoint2,YPoint2: Integer); var YHilfsPoint, XHilfsPoint: Integer; begin gamma := 90; a := c/1.41; b := sqrt((c*c) - (a*a)); c1 := b; alpha := arcsin(a * sin(gamma/180*PI) / c) * (180/PI); OldAlpha := OldAlpha + alpha; c := b; // Dreieckberechnung gamma := 90; alpha := 90 - OldAlpha; beta := 180 - gamma - alpha; XHilfsPoint := Round(XPoint1+(c * sin(alpha/180*PI) / sin(gamma/180*PI))); YHilfsPoint := Round(YPoint1-(c * sin(beta/180*PI) / sin(gamma/180*PI))); zaehler := zaehler + 1; // Berechnung für den OberenPunkt (Punkt C) if zaehler <= Ast then begin // ersterdruchschlauf Image1.Canvas.Polygon([Point(XPoint1,YPoint1),Point(XPoint2,YPoint2), Point(XHilfsPoint,YHilfsPoint)]); PaintTree_NewViereck(XHilfsPoint,YHilfsPoint,XPoint2,YPoint2); // Viereck Rechteseite Dreieck PaintTree_Viereck(XPoint1,YPoint1,XHilfsPoint,YHilfsPoint); // Viereck Linkeseite Dreieck end else if ast <> 1 then begin // aufbau das Bames Linkes Viereck i := i + 1; Ast := Ast - 1; zaehler := ast-i; Oldalpha := Old_alpha[Tiefe-i,0] - 90; c := SeitenLaenge[Tiefe-i,0]; // neue Werte fürs Dreieck zugewiesen PaintTree_Dreieck(X_Point1[Tiefe-i,0],Y_Point1[Tiefe-i,0],X_Point2[Tiefe-i,0],Y_Point2[Tiefe-i,0]); // Dreieck zeichnen end else begin //---->anfang-test<--- // ast := Tiefe; // PaintTree_Dreieck(X_Point1[row,0],Y_Point1[row,0],X_Point2[row,0],Y_Point2[row,0]); Image1.Canvas.Pen.Color := clRed; Image1.Canvas.MoveTo(X_Point1[row-4,0],Y_Point1[row-4,0]); Image1.Canvas.LineTo(X_Point2[row-4,0],Y_Point2[row-4,0]); Image1.Canvas.Pen.Color := clBlack; //----->Yende-test<---- end; end;
procedure TForm1.PaintTree_Viereck(XPoint1,YPoint1,XPoint2,YPoint2: Integer); var XHPoint1, YHPoint1: Integer; YHilfsPoint, XHilfsPoint: Integer; begin XHPoint1 := XPoint1; YHPoint1 := YPoint1; alpha := 90; beta := 180 - 90 - oldalpha; gamma := 180 - alpha - beta; XPoint1 := Round(XPoint1-(c * sin(gamma/180*PI) / sin(alpha/180*PI))); YPoint1 := Round(YPoint1-(c * sin(beta/180*PI) / sin(alpha/180*PI))); XHilfsPoint := Round(XPoint1+(c * sin(beta/180*PI) / sin(alpha/180*PI))); YHilfsPoint := Round(YPoint1-(c * sin(gamma/180*PI) / sin(alpha/180*PI))); Image1.Canvas.Polygon([Point(XHPoint1,YHPoint1),Point(XPoint1,YPoint1), Point(XHilfsPoint,YHilfsPoint),Point(XPoint2,YPoint2)]); // Viereckzeichnen PaintTree_Dreieck(XPoint1,YPoint1,XHilfsPoint,YHilfsPoint); //Dreieck aufrufen end;
procedure TForm1.PaintTree_NewViereck(XPoint1,YPoint1,XPoint2,YPoint2: Integer); var XHPoint2, YHPoint2: Integer; XHPoint1, YHPoint1: Integer; begin alpha := 90; beta := 180 - 90 - oldalpha; gamma := 180 - alpha - beta; XHPoint2 := XPoint2; YHPoint2 := YPoint2; XHPoint1 := XPoint1; YHPoint1 := YPoint1; XPoint2 := Round(XHPoint2+(a * sin(beta/180*PI) / sin(alpha/180*PI))); YPoint2 := Round(YHPoint2-(a * sin(gamma/180*PI) / sin(alpha/180*PI))); XPoint1 := Round(XPoint2-(a * sin(gamma/180*PI) / sin(alpha/180*PI))); YPoint1 := Round(YPoint2-(a * sin(beta/180*PI) / sin(alpha/180*PI))); Image1.Canvas.Polygon([Point(XHPoint1,YHPoint1),Point(XPoint1,YPoint1), Point(XPoint2,YPoint2),Point(XHPoint2,YHPoint2)]); //Viereckzeichnen row := row +1; SeitenLaenge[row,0]:= a; Old_alpha[row,0] := Oldalpha; X_Point1[row,0] := XPoint1; Y_Point1[row,0] := YPoint1; X_Point2[row,0] := XPoint2; Y_Point2[row,0] := YPoint2; //Werte speichern end;
end. |