|
more than 450 programs for free
|
![]() English |
![]() Slovensky |
![]() Česky |
![]() Šarišsky |
|
Category: Geometry Program: Poilinp.pas, Poilinu.pas File exe: Poilinp.exe, Poilinu.tpu need: Angeom02.tpu, Uninout.tpu, Egavga.bgi flow: Poilin.doc, Amater.txt Example: Angeom02.pas, Uninout.pas For units AnGeom02 (algebraics geometry) make function Distance_LP. This function compute distance between point and line.
FUNCTION Distance_LP(Line1:TLine; bodA:TPoint): Real; Views: 765x
{ Unit - zadanie z Objektovo orientovaneho programovania } { Autor: Ja } UNIT PoiLinU; INTERFACE USES AnGeom02; FUNCTION Distance_LP(Line1:TLine; bodA:TPoint): Real; IMPLEMENTATION { Funkcia vypocita vzdialenost bodu od priamky. } { Pred vypoctom testuje ci bod, alebo priamka existuju. } { V debug rezime vypisuje pripadne chyby ktore nastanu. } FUNCTION Distance_LP(Line1:TLine; bodA:TPoint): Real; var err : boolean; mez, sq : real; { medzivysledok } begin { Najprv dame default ktory tam zostane v pripade neuspechu } Distance_LP := -1.0; err := false; { bod ktory chcem pouzit nieje definovany } if( bodA.bYnit = false )then begin Error( 1, 'Bod pre urcenie vzdialenosti bodu od priamky neexistuje', 'Distance_LP', '' ); err := true; end; { line ktoru chcem pouzit nieje definovana } if( Line1.bYnit = false )then begin Error( 1, 'Priamka pre urcenie vzdialenosti bodu od priamky neexistuje', 'Distance_LP', '' ); err := true; end; { samotny vypocet, len ak existuju bod a priamka } if (err = false )then begin mez := Line1.a * bodA.ox + Line1.b * bodA.oy + Line1.c; sq := Sqr(Line1.a) + Sqr(Line1.b); { este kontrola delenia nulou - teoreticky nemoze nastat lebo uz boli kontroly } if( sq=0 )then Error( 1, 'Vyskytla sa chyba delenia nulou pri pocitani vzdialenosti bodu od priamky', 'Distance_LP', '' ) else Distance_LP := Abs( mez ) / Sqrt( sq ); end; end; { Distance_LP } { hlavne begin-end unity } begin end. [Save] [Print] [Send e-mail] |
|