Einzelnen Beitrag anzeigen

Benutzerbild von Bummi
Bummi

Registriert seit: 15. Jun 2010
Ort: Augsburg Bayern Süddeutschland
3.470 Beiträge
 
Delphi XE3 Enterprise
 
#9

AW: Drei Werte als Punkt im Dreieck darstellen

  Alt 2. Okt 2012, 12:36
@Lemmy
die Division / 3 ist zuviel .....

Delphi-Quellcode:
procedure TForm3.Button1Click(Sender: TObject);
Type
 TParry=Array [0..3] of Tpoint;
 TCMP=Array[0..2] of Double;
var
  p,hp:TParry;
  CMP:TCMP;
  zp:Tpoint;
begin
   p[0].x := 0;
   p[0].y := 0;
   p[1].x := 300;
   p[1].y := 0;
   p[2].x := (p[1].x - p[0].x) div 2;
   p[2].y := Round(Sin(DegToRad(60))*(p[1].x - p[0].x) + p[0].x );
   p[3] := p[0];

   CMP[0] := 0.5;
   CMP[1] := 0.5;
   CMP[2] := 0.9;
{
  CMP[0] := 0.5;
  CMP[1] := 0.5;
  CMP[2] := 0.5;
}

   Assert(CMP[0]+ CMP[1]+ CMP[2] <> 0);
   zp.x := Round(((CMP[0]*p[0].x)/( CMP[0]+ CMP[1]+ CMP[2]) + (CMP[1]*p[1].x)/( CMP[0]+ CMP[1]+ CMP[2]) + (CMP[2]*p[2].x)/( CMP[0]+ CMP[1]+ CMP[2])));
   zp.y := Round(((CMP[0]*p[0].y)/( CMP[0]+ CMP[1]+ CMP[2]) + (CMP[1]*p[1].y)/( CMP[0]+ CMP[1]+ CMP[2]) + (CMP[2]*p[2].y)/( CMP[0]+ CMP[1]+ CMP[2])));

   Image1.Canvas.Polyline(p);
   image1.Canvas.Ellipse(zp.x-2,zp.y-2,zp.x+2,zp.y+2);

end;
Thomas Wassermann H₂♂
Das Problem steckt meistens zwischen den Ohren
DRY DRY KISS
H₂ (wenn bei meinen Snipplets nichts anderes angegeben ist Lizenz: WTFPL)

Geändert von Bummi ( 2. Okt 2012 um 13:22 Uhr)
  Mit Zitat antworten Zitat