added triang.c
authorhackbard <hackbard>
Thu, 8 Aug 2002 18:53:37 +0000 (18:53 +0000)
committerhackbard <hackbard>
Thu, 8 Aug 2002 18:53:37 +0000 (18:53 +0000)
triang.c [new file with mode: 0644]

diff --git a/triang.c b/triang.c
new file mode 100644 (file)
index 0000000..34b2ffe
--- /dev/null
+++ b/triang.c
@@ -0,0 +1,57 @@
+#include <stdio.h>
+#include <math.h>
+
+#define MAXSIGNAL 100
+
+double *delta1, *delta2; 
+
+       /*
+       zweite Loesung ist achsensymmetrisch zur Verbindungslinie
+       zwischen Freund und einem selbst, also nur dX und dY vertauscht. 
+       */
+
+void seek_target (float X1, float Y1, float X2, float Y2, int E1, int E2) {
+       
+       /* (X1,Y1) eigene Koordinaten */
+       /* (X2,Y2) freundliche Koordinaten */
+       /* E1 eigene Signalstaerke vom target */
+       /* E2 Signalstaerke des Targets vom Freund */
+
+// printf("Debug: %f %f %f %f %d %d \n", X1, Y1, X2, Y2, E1, E2);
+
+double zaehler, nenner, zusatz;
+
+zaehler=MAXSIGNAL*(1./E1-1./E2)-(X1-X2)*(X1-X2)-(Y1-Y2)*(Y1-Y2);
+nenner=2*sqrt((X1-X2)*(X1-X2)+(Y1-Y2)*(Y1-Y2));
+zusatz=sqrt((double)E1/E2);
+
+*delta1=acos(zaehler/(nenner*zusatz));
+*delta2=zaehler/nenner;
+}
+
+main() {
+
+/* beispiel */
+
+printf("Debug: funzt noch ...\n");
+
+float a, b, c, d;
+int e, f;
+
+a=0;
+b=0;
+c=0;
+d=10;
+e=90;
+f=35;
+
+seek_target (a, b, c, d, e, f);
+/* wir sind im ursprung, kumpel 10 einheiten ueber uns! */
+
+printf("Debug: seek_target ausgefuehrt!\n");
+
+printf("1. Moeglichkeit: (%f;%f)\n", *delta1, *delta2);
+printf("2. Moeglichkeit: (%f;%f)\n", *delta2, *delta1);
+
+}
+