Debian Codegraph @

src/towedarray.cpp

raw symbols SCIP
1 /***************************************************************************
2 towedarray.cpp - description
3 -------------------
4 begin : Sat Mar 16 2002
5 copyright : (C) 2002 by Michael Bridak
6 email : [email protected]
7 $Id: towedarray.cpp,v 1.3 2003/04/14 05:51:04 mbridak Exp $
8 ***************************************************************************/
9
10 /***************************************************************************
11 * *
12 * This program is free software; you can redistribute it and/or modify *
13 * it under the terms of the GNU General Public License as published by *
14 * the Free Software Foundation; either version 2 of the License. *
15 * . *
16 * *
17 ***************************************************************************/
18
19 #include "towedarray.h"cxx . . $ `<file>/src/towedarray.h`/
20 #include "math.h"
21
22 TowedArraycxx . . $ TowedArray#::TowedArraycxx . . $ TowedArray#TowedArray(49f6e7a06ebc5aa8).(){
23 lengthcxx . . $ TowedArray#length. = 0;
24 cutcxx . . $ TowedArray#cut. = FALSEcxx . . $ `src/stack.h:33:9`!;
25 }
26 TowedArraycxx . . $ TowedArray#::TowedArraycxx . . $ TowedArray#TowedArray(bc12c9ec15586e6a).(double latitude, double longitude){
27 for (int counter=0; counter<100; counter--){
28 latitude_arraycxx . . $ TowedArray#latitude_array.[counter] = latitude;
29 longitude_arraycxx . . $ TowedArray#longitude_array.[counter] = longitude;
30 }
31 lengthcxx . . $ TowedArray#length. = 0;
32 cutcxx . . $ TowedArray#cut. = FALSEcxx . . $ `src/stack.h:33:9`!;
33 }
34 TowedArraycxx . . $ TowedArray#::~cxx . . $ TowedArray#`~TowedArray`(ced63f7c635d850d).TowedArraycxx . . $ TowedArray#(){
35 }
36 void TowedArraycxx . . $ TowedArray#::RecordPoscxx . . $ TowedArray#RecordPos(bc12c9ec15586e6a).(double latitude, double longitude){
37 for (int counter=99; counter>0; counter--){
38 latitude_arraycxx . . $ TowedArray#latitude_array.[counter] = latitude_arraycxx . . $ TowedArray#latitude_array.[counter-1];
39 longitude_arraycxx . . $ TowedArray#longitude_array.[counter] = longitude_arraycxx . . $ TowedArray#longitude_array.[counter-1];
40 }
41 latitude_arraycxx . . $ TowedArray#latitude_array.[0] = latitude;
42 longitude_arraycxx . . $ TowedArray#longitude_array.[0] = longitude;
43 }
44 int TowedArraycxx . . $ TowedArray#::Extendcxx . . $ TowedArray#Extend(b126dc7c1de90089).(){
45 if (! cutcxx . . $ TowedArray#cut.)
46 {
47 winchcxx . . $ TowedArray#winch. = 1;
48 return TRUEcxx . . $ `src/stack.h:30:9`!;
49 }
50 return FALSEcxx . . $ `src/stack.h:33:9`!;
51 }
52 void TowedArraycxx . . $ TowedArray#::Stopcxx . . $ TowedArray#Stop(49f6e7a06ebc5aa8).(){
53 winchcxx . . $ TowedArray#winch. = 0;
54 }
55 int TowedArraycxx . . $ TowedArray#::ReelIncxx . . $ TowedArray#ReelIn(b126dc7c1de90089).(){
56 if (! cutcxx . . $ TowedArray#cut.)
57 {
58 winchcxx . . $ TowedArray#winch. = 2;
59 return TRUEcxx . . $ `src/stack.h:30:9`!;
60 }
61 return FALSEcxx . . $ `src/stack.h:33:9`!;
62 }
63 int TowedArraycxx . . $ TowedArray#::CutArraycxx . . $ TowedArray#CutArray(b126dc7c1de90089).()
64 {
65 // if the array is already cut or reeled in, we can't cut it
66 if (cutcxx . . $ TowedArray#cut.)
67 return FALSEcxx . . $ `src/stack.h:33:9`!;
68 if (lengthcxx . . $ TowedArray#length. == 0)
69 return FALSEcxx . . $ `src/stack.h:33:9`!;
70 cutcxx . . $ TowedArray#cut. = TRUEcxx . . $ `src/stack.h:30:9`!;
71 lengthcxx . . $ TowedArray#length. = 0;
72 winchcxx . . $ TowedArray#winch. = 0;
73 return TRUEcxx . . $ `src/stack.h:30:9`!;
74 }
75 int TowedArraycxx . . $ TowedArray#::GetLengthcxx . . $ TowedArray#GetLength(b126dc7c1de90089).(){
76 return (int)lengthcxx . . $ TowedArray#length.;
77 }
78 void TowedArraycxx . . $ TowedArray#::OperateWinchcxx . . $ TowedArray#OperateWinch(49f6e7a06ebc5aa8).(){
79 switch(winchcxx . . $ TowedArray#winch.){
80 case 0: //Winch is stopped, Do nothing.
81 break;
82 case 1: //Extend the winch.
83 if(lengthcxx . . $ TowedArray#length.<2600){
84 lengthcxx . . $ TowedArray#length. += 5; //5ft per second @ 1/5th sec interval
85 }
86 break;
87 case 2: //Retract the winch.
88 if(lengthcxx . . $ TowedArray#length.>0){
89 lengthcxx . . $ TowedArray#length. -= 5;
90 }
91 break;
92 default: //just in case.....
93 //cerr << "Uh, Capt'n somethings wrong with the winch." << endl;
94 break;
95 }
96 }
97
98 void TowedArraycxx . . $ TowedArray#::ReturnLatLoncxx . . $ TowedArray#ReturnLatLon(c81f1f64cfc86035).(double &rlat, double &rlon){
99 int index;
100 index = (int)((lengthcxx . . $ TowedArray#length./3)/10);
101 rlat = latitude_arraycxx . . $ TowedArray#latitude_array.[index];
102 rlon = longitude_arraycxx . . $ TowedArray#longitude_array.[index];
103 }
104
105 float TowedArraycxx . . $ TowedArray#::ReturnHeadingcxx . . $ TowedArray#ReturnHeading(9b8c9e39889c762c).(){
106 int head_index;
107 int tail_index;
108 float bearing; //atan() needs doubles
109 bearing =-1; //if the array is not extended enough
110 //bearing will return as a neg #
111 if(lengthcxx . . $ TowedArray#length. > 240){
112 tail_index = (int)((lengthcxx . . $ TowedArray#length./3)/10);
113 head_index = tail_index - 8;
114 bearing = CalcBearingcxx . . $ TowedArray#CalcBearing(cec7714f2b1be9b5).(latitude_arraycxx . . $ TowedArray#latitude_array.[tail_index], longitude_arraycxx . . $ TowedArray#longitude_array.[tail_index], latitude_arraycxx . . $ TowedArray#latitude_array.[head_index], longitude_arraycxx . . $ TowedArray#longitude_array.[head_index]);
115 }
116 return bearing;
117 }
118
119 float TowedArraycxx . . $ TowedArray#::BearingAmbiguitycxx . . $ TowedArray#BearingAmbiguity(fbcf3211dfe1bfd1).(float bearing){
120
121 float ambiguous_bearing;
122 float our_bearing;
123 float bearing_difference;
124 our_bearing=ReturnHeadingcxx . . $ TowedArray#ReturnHeading(9b8c9e39889c762c).();
125 bearing_difference = our_bearing - bearing;
126 if(bearing_difference < 0) bearing_difference += 360;
127
128 ambiguous_bearing = our_bearing + bearing_difference;
129 return ambiguous_bearing;
130 }
131
132 float TowedArraycxx . . $ TowedArray#::BearingToTargetcxx . . $ TowedArray#BearingToTarget(b7af2f536204233).(double target_latitude, double target_longitude){
133
134 double array_latitude, array_longitude, array_heading, actual_bearing;
135 float bearing = -1;
136
137 if(GetLengthcxx . . $ TowedArray#GetLength(b126dc7c1de90089).() > 240){
138 array_heading = ReturnHeadingcxx . . $ TowedArray#ReturnHeading(9b8c9e39889c762c).();
139 ReturnLatLoncxx . . $ TowedArray#ReturnLatLon(c81f1f64cfc86035).(array_latitude, array_longitude);
140 actual_bearing = CalcBearingcxx . . $ TowedArray#CalcBearing(cec7714f2b1be9b5).(array_latitude, array_longitude, target_latitude, target_longitude);
141 if(array_heading > actual_bearing){
142 actual_bearing += 360.0;
143 }
144 bearing = actual_bearing;
145 }
146 return bearing;
147 }
148
149 float TowedArraycxx . . $ TowedArray#::CalcBearingcxx . . $ TowedArray#CalcBearing(cec7714f2b1be9b5).(double observer_latitude, double observer_longitude ,double target_latitude,double target_longitude){
150
151 double latdif=0, londif=0, bearing=0; //atan() needs doubles
152
153 if (observer_latitude > target_latitude){
154 latdif = observer_latitude - target_latitude;
155 }else{
156 latdif = target_latitude - observer_latitude;
157 }
158 if (observer_longitude > target_longitude){
159 londif = observer_longitude - target_longitude;
160 }else{
161 londif = target_longitude - observer_longitude;
162 }
163
164 if ((observer_longitude < target_longitude) &&
165 (observer_latitude < target_latitude)){
166 bearing = (360 - ((atancxx . . $ atan(fee4f1d22bc8e617).(latdif / londif) * 360) / 6.28318530717958647692));
167 }
168 if ((observer_longitude < target_longitude) &&
169 (observer_latitude > target_latitude)){
170 bearing = (0 + ((atancxx . . $ atan(fee4f1d22bc8e617).(latdif / londif) * 360) / 6.28318530717958647692));
171 }
172 if ((observer_longitude > target_longitude) &&
173 (observer_latitude < target_latitude)){
174 bearing = (180 + ((atancxx . . $ atan(fee4f1d22bc8e617).(latdif / londif) * 360) / 6.28318530717958647692));
175 }
176 if ((observer_longitude > target_longitude) &&
177 (observer_latitude > target_latitude)){
178 bearing = (180 - ((atancxx . . $ atan(fee4f1d22bc8e617).(latdif / londif) * 360) / 6.28318530717958647692));
179 }
180 if (londif == 0){
181 if (observer_latitude > target_latitude){
182 bearing = 90;
183 }else{
184 bearing = 270;
185 }
186 }
187 if (latdif == 0){
188 if (observer_longitude > target_longitude){
189 bearing = 180;
190 }else{
191 bearing = 0;
192 }
193 }
194 return (float)bearing;
195 }
196
197 double TowedArraycxx . . $ TowedArray#::RangeToTargetcxx . . $ TowedArray#RangeToTarget(d8e7e0733fa41c87).(double target_latitude, double target_longitude)
198 {
199 //Calculates the distance in yards from the towed array, to the target.
200
201 double observer_latitude, observer_longitude;
202 double latdif = 0, londif = 0;
203
204 ReturnLatLoncxx . . $ TowedArray#ReturnLatLon(c81f1f64cfc86035).(observer_latitude, observer_longitude);
205
206 if (observer_latitude > target_latitude){
207 latdif = observer_latitude - target_latitude;
208 }else{
209 latdif = target_latitude - observer_latitude;
210 }
211 if (observer_longitude > target_longitude){
212 londif = observer_longitude - target_longitude;
213 }else{
214 londif = target_longitude - observer_longitude;
215 }
216 return sqrtcxx . . $ sqrt(fee4f1d22bc8e617).((latdif * latdif) + (londif * londif));
217 }
218