![]() |
Re: Punkt in Dreieck?
@All,
will Eure Leistung auch nicht schmaelern. Aber es geht auch allgemeinguelting ohne Division.
Delphi-Quellcode:
eidts: falsche fehlertype TSimplePoint = record x,y : Double; end; . . . function bSubPoints(p1,p2:TSimplePoint):TSimplePoint; begin result.x := p1.x-p2.x; result.y := p1.y-p2.y; end; function bPointInTriangle(Tri1,Tri2,Tri3,APnt:TSimplePoint):Boolean; var a,b,c : Double; T1,T2,T3 : TSimplePoint; begin // Zwillinger - Standard Mathematical Tables and Formulae, 31st Ed [CRC Press 2003] // Kapitel 4 Geometrie Abs 4.5 Polygone // FIRST PLACE ANY POINT TO ZERO(0,0) AND MOVE THE OTHERS RESPECTIVLY --> HERE Tri1 T1 := bSubPoints(Tri2,Tri1); T2 := bSubPoints(Tri3,Tri1); T3 := bSubPoints(APnt,Tri1); // COMPUTE a := (T1.x*T2.y)-(T2.x*T1.y); b := (T1.x*T3.y)-(T3.x*T1.y); c := (T2.x*T3.y)-(T3.x*T2.y); // RESULT result := Boolean( ((a*b)>0) AND ((a*c)<0) AND ((a*(a-b+c))>0) ); // if TRUE then POINT IS IN THE TRIANGLE end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 01:38 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