From: anonymous Date: Fri, 9 Aug 2002 02:48:06 +0000 (+0000) Subject: formatted source :-) X-Git-Url: https://hackdaworld.org/gitweb/?a=commitdiff_plain;h=58bea45da9bbd1b132b86dad5ebfb7ad8ad757b2;p=my-code%2Ftriang.git formatted source :-) --- diff --git a/triang.c b/triang.c index 8f4a706..eb1f6a6 100644 --- a/triang.c +++ b/triang.c @@ -1,3 +1,7 @@ +/* + * triang.c + */ + #include #include @@ -18,56 +22,59 @@ void seek_target (float X1, float Y1, float X2, float Y2, int E1, int E2) { /* E1 eigene Signalstaerke vom target */ /* E2 Signalstaerke des Targets vom Freund */ -double zaehler, nenner, a_q, b_q, c_q, deltaX, deltaY; - -printf("Debug: %f %f %f %f %d %d \n", X1, Y1, X2, Y2, E1, E2); - -/* quadratwerte der seitenlaengen im dreieck */ -a_q=(double)MAXSIGNAL/E2; -b_q=(double)MAXSIGNAL/E1; -c_q=(X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2); - -/* hilfsvariablen */ -deltaX=X1-X2; -deltaY=Y1-Y2; -zaehler=a_q-b_q-c_q; -nenner=-2*sqrt(c_q*b_q); - -printf("Debug: a=%f , b=%f ... und c=%f\n", sqrt(a_q), sqrt(b_q), sqrt(c_q)); - -if ( (sqrt(a_q)+sqrt(b_q)) <= sqrt(c_q) ) { - printf("impossible situation!\n"); - deltaX1=0; deltaY1=0; -} -else { - deltaX1=-sqrt(b_q)*cos(acos(deltaX/deltaY)-acos(zaehler/nenner)); - deltaY1=sqrt(b_q)*sin(acos(deltaX/deltaY)-acos(zaehler/nenner)); - deltaX2=deltaY1; - deltaY2=-1*deltaX1; + double zaehler, nenner, a_q, b_q, c_q, deltaX, deltaY; + + printf("Debug: %f %f %f %f %d %d \n", X1, Y1, X2, Y2, E1, E2); + + /* quadratwerte der seitenlaengen im dreieck */ + a_q=(double)MAXSIGNAL/E2; + b_q=(double)MAXSIGNAL/E1; + c_q=(X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2); + + /* hilfsvariablen */ + deltaX=X1-X2; + deltaY=Y1-Y2; + zaehler=a_q-b_q-c_q; + nenner=-2*sqrt(c_q*b_q); + + printf("Debug: a=%f , b=%f ... und c=%f\n", sqrt(a_q), sqrt(b_q), sqrt(c_q)); + + if ( (sqrt(a_q)+sqrt(b_q)) <= sqrt(c_q) ) + { + printf("impossible situation!\n"); + deltaX1=0; deltaY1=0; + } + else + { + deltaX1=-sqrt(b_q)*cos(acos(deltaX/deltaY)-acos(zaehler/nenner)); + deltaY1=sqrt(b_q)*sin(acos(deltaX/deltaY)-acos(zaehler/nenner)); + deltaX2=deltaY1; + deltaY2=-1*deltaX1; + } } -} - -main() { -/* beispiel */ +int main (int argc, char ** argv) +{ + /* beispiel */ -float a, b, c, d; -int e, f; + float a, b, c, d; + int e, f; -a=0; -b=0; -c=0; -d=10; -e=5; -f=2; + a=0; + b=0; + c=0; + d=10; + e=5; + f=2; -seek_target (a, b, c, d, e, f); -/* wir sind im ursprung, kumpel 10 einheiten ueber uns! */ + seek_target (a, b, c, d, e, f); + /* wir sind im ursprung, kumpel 10 einheiten ueber uns! */ -printf("Debug: seek_target ausgefuehrt!\n"); + printf("Debug: seek_target ausgefuehrt!\n"); -printf("1. Moeglichkeit: Delta(%f;%f)\n", deltaX1, deltaY1); -printf("2. Moeglichkeit: Delta(%f;%f)\n", deltaX2, deltaY2); + printf("1. Moeglichkeit: Delta(%f;%f)\n", deltaX1, deltaY1); + printf("2. Moeglichkeit: Delta(%f;%f)\n", deltaX2, deltaY2); + return 0; }