1 |
|
---|
2 | // Part of BNC, a utility for retrieving decoding and
|
---|
3 | // converting GNSS data streams from NTRIP broadcasters.
|
---|
4 | //
|
---|
5 | // Copyright (C) 2007
|
---|
6 | // German Federal Agency for Cartography and Geodesy (BKG)
|
---|
7 | // http://www.bkg.bund.de
|
---|
8 | // Czech Technical University Prague, Department of Geodesy
|
---|
9 | // http://www.fsv.cvut.cz
|
---|
10 | //
|
---|
11 | // Email: euref-ip@bkg.bund.de
|
---|
12 | //
|
---|
13 | // This program is free software; you can redistribute it and/or
|
---|
14 | // modify it under the terms of the GNU General Public License
|
---|
15 | // as published by the Free Software Foundation, version 2.
|
---|
16 | //
|
---|
17 | // This program is distributed in the hope that it will be useful,
|
---|
18 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
19 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
20 | // GNU General Public License for more details.
|
---|
21 | //
|
---|
22 | // You should have received a copy of the GNU General Public License
|
---|
23 | // along with this program; if not, write to the Free Software
|
---|
24 | // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
25 |
|
---|
26 | /* -------------------------------------------------------------------------
|
---|
27 | * BKG NTRIP Client
|
---|
28 | * -------------------------------------------------------------------------
|
---|
29 | *
|
---|
30 | * Class: t_pppClient
|
---|
31 | *
|
---|
32 | * Purpose: PPP Client processing starts here
|
---|
33 | *
|
---|
34 | * Author: L. Mervart
|
---|
35 | *
|
---|
36 | * Created: 29-Jul-2014
|
---|
37 | *
|
---|
38 | * Changes:
|
---|
39 | *
|
---|
40 | * -----------------------------------------------------------------------*/
|
---|
41 |
|
---|
42 | #include <QThreadStorage>
|
---|
43 |
|
---|
44 | #include <iostream>
|
---|
45 | #include <iomanip>
|
---|
46 | #include <stdlib.h>
|
---|
47 | #include <string.h>
|
---|
48 | #include <stdexcept>
|
---|
49 |
|
---|
50 | #include "pppClient.h"
|
---|
51 | #include "ephpool.h"
|
---|
52 | #include "obspool.h"
|
---|
53 | #include "satbias.h"
|
---|
54 | #include "bncconst.h"
|
---|
55 | #include "bncutils.h"
|
---|
56 | #include "station.h"
|
---|
57 | #include "bnctides.h"
|
---|
58 | #include "bncantex.h"
|
---|
59 | #include "filter.h"
|
---|
60 |
|
---|
61 | using namespace BNC;
|
---|
62 | using namespace std;
|
---|
63 |
|
---|
64 | // Global variable holding thread-specific pointers
|
---|
65 | //////////////////////////////////////////////////////////////////////////////
|
---|
66 | QThreadStorage<t_pppClient*> CLIENTS;
|
---|
67 |
|
---|
68 | // Static function returning thread-specific pointer
|
---|
69 | //////////////////////////////////////////////////////////////////////////////
|
---|
70 | t_pppClient* t_pppClient::instance() {
|
---|
71 | return CLIENTS.localData();
|
---|
72 | }
|
---|
73 |
|
---|
74 | // Constructor
|
---|
75 | //////////////////////////////////////////////////////////////////////////////
|
---|
76 | t_pppClient::t_pppClient() {
|
---|
77 | _opt = 0;
|
---|
78 | _output = 0;
|
---|
79 | _antex = 0;
|
---|
80 | _log = new ostringstream();
|
---|
81 | _ephPool = new t_ephPool();
|
---|
82 | _obsPool = new t_obsPool();
|
---|
83 | _staRover = new t_station();
|
---|
84 | _filter = new t_filter();
|
---|
85 | CLIENTS.setLocalData(this); // CLIENTS takes ownership over "this"
|
---|
86 | }
|
---|
87 |
|
---|
88 | // Destructor
|
---|
89 | //////////////////////////////////////////////////////////////////////////////
|
---|
90 | t_pppClient::~t_pppClient() {
|
---|
91 | cout << "~t_pppClient" << endl;
|
---|
92 | delete _log;
|
---|
93 | delete _opt;
|
---|
94 | delete _ephPool;
|
---|
95 | delete _obsPool;
|
---|
96 | delete _staRover;
|
---|
97 | delete _antex;
|
---|
98 | delete _filter;
|
---|
99 | clearObs();
|
---|
100 | }
|
---|
101 |
|
---|
102 | //
|
---|
103 | //////////////////////////////////////////////////////////////////////////////
|
---|
104 | void t_pppClient::setOptions(const t_options* opt) {
|
---|
105 | delete _opt;
|
---|
106 | _opt = new t_options(*opt);
|
---|
107 |
|
---|
108 | delete _antex; _antex = 0;
|
---|
109 | if (!_opt->_antexFile.empty()) {
|
---|
110 | _antex = new bncAntex(_opt->_antexFile.c_str());
|
---|
111 | }
|
---|
112 | }
|
---|
113 |
|
---|
114 | //
|
---|
115 | //////////////////////////////////////////////////////////////////////////////
|
---|
116 | void t_pppClient::putGPSEphemeris(const t_ephGPS* eph) {
|
---|
117 | cout << "t_pppClient::putGPSEphemeris " << PPP_CLIENT << endl;
|
---|
118 | _ephPool->putEphemeris(new t_ephGPS(*eph));
|
---|
119 | }
|
---|
120 |
|
---|
121 | //
|
---|
122 | //////////////////////////////////////////////////////////////////////////////
|
---|
123 | void t_pppClient::putGloEphemeris(const t_ephGlo* eph) {
|
---|
124 | _ephPool->putEphemeris(new t_ephGlo(*eph));
|
---|
125 | }
|
---|
126 |
|
---|
127 | //
|
---|
128 | //////////////////////////////////////////////////////////////////////////////
|
---|
129 | void t_pppClient::putOrbCorrections(int numCorr, const t_orbCorr* corr) {
|
---|
130 | for (int ii = 0; ii < numCorr; ii++) {
|
---|
131 | _ephPool->putOrbCorrection(new t_orbCorr(corr[ii]));
|
---|
132 | }
|
---|
133 | }
|
---|
134 |
|
---|
135 | //
|
---|
136 | //////////////////////////////////////////////////////////////////////////////
|
---|
137 | void t_pppClient::putClkCorrections(int numCorr, const t_clkCorr* corr) {
|
---|
138 | for (int ii = 0; ii < numCorr; ii++) {
|
---|
139 | _ephPool->putClkCorrection(new t_clkCorr(corr[ii]));
|
---|
140 | }
|
---|
141 | }
|
---|
142 |
|
---|
143 | //
|
---|
144 | //////////////////////////////////////////////////////////////////////////////
|
---|
145 | void t_pppClient::putBiases(int numBiases, const t_satBiases* biases) {
|
---|
146 | for (int ii = 0; ii < numBiases; ii++) {
|
---|
147 | _obsPool->putBiases(new t_satBias(biases[ii]));
|
---|
148 | }
|
---|
149 | }
|
---|
150 |
|
---|
151 | //
|
---|
152 | //////////////////////////////////////////////////////////////////////////////
|
---|
153 | t_irc t_pppClient::prepareObs(int numSat, const t_pppSatObs* satObs,
|
---|
154 | vector<t_satObs*>& obsVector, bncTime& epoTime) {
|
---|
155 | // Default
|
---|
156 | // -------
|
---|
157 | epoTime.reset();
|
---|
158 |
|
---|
159 | // Create vector of valid observations
|
---|
160 | // -----------------------------------
|
---|
161 | int numValidGPS = 0;
|
---|
162 | for (int ii = 0; ii < numSat; ii++) {
|
---|
163 | char system = satObs[ii]._prn.system();
|
---|
164 | if (system == 'G' || (system == 'R' && OPT->useGlonass())) {
|
---|
165 | t_satObs* satObs = new t_satObs(satObs[ii]);
|
---|
166 | if (satObs->isValid()) {
|
---|
167 | obsVector.push_back(satObs);
|
---|
168 | if (satObs->prn().system() == 'G') {
|
---|
169 | ++numValidGPS;
|
---|
170 | }
|
---|
171 | }
|
---|
172 | else {
|
---|
173 | delete satObs;
|
---|
174 | }
|
---|
175 | }
|
---|
176 | }
|
---|
177 |
|
---|
178 | // Check whether data are synchronized, compute epoTime
|
---|
179 | // ----------------------------------------------------
|
---|
180 | const double MAXSYNC = 0.05; // synchronization limit
|
---|
181 | double meanDt = 0.0;
|
---|
182 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
183 | const t_satObs* satObs = obsVector.at(ii);
|
---|
184 | if (epoTime.undef()) {
|
---|
185 | epoTime = satObs->time();
|
---|
186 | }
|
---|
187 | else {
|
---|
188 | double dt = satObs->time() - epoTime;
|
---|
189 | if (fabs(dt) > MAXSYNC) {
|
---|
190 | LOG << "t_pppClient::prepareObs asynchronous observations" << endl;
|
---|
191 | return failure;
|
---|
192 | }
|
---|
193 | meanDt += dt;
|
---|
194 | }
|
---|
195 | }
|
---|
196 | epoTime += meanDt / obsVector.size();
|
---|
197 |
|
---|
198 | return success;
|
---|
199 | }
|
---|
200 |
|
---|
201 | // Compute the Bancroft position, check for blunders
|
---|
202 | //////////////////////////////////////////////////////////////////////////////
|
---|
203 | t_irc t_pppClient::cmpBancroft(const bncTime& epoTime,
|
---|
204 | vector<t_satObs*>& obsVector,
|
---|
205 | ColumnVector& xyzc, bool print) {
|
---|
206 |
|
---|
207 | t_lc::type tLC = (OPT->dualFreqRequired() ? t_lc::cIF : t_lc::c1);
|
---|
208 |
|
---|
209 | while (true) {
|
---|
210 | Matrix BB(obsVector.size(), 4);
|
---|
211 | int iObs = -1;
|
---|
212 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
213 | const t_satObs* satObs = obsVector.at(ii);
|
---|
214 | if ( satObs->isValid() && satObs->prn().system() == 'G' &&
|
---|
215 | (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) {
|
---|
216 | ++iObs;
|
---|
217 | BB[iObs][0] = satObs->xc()[0];
|
---|
218 | BB[iObs][1] = satObs->xc()[1];
|
---|
219 | BB[iObs][2] = satObs->xc()[2];
|
---|
220 | BB[iObs][3] = satObs->obsValue(tLC) - satObs->cmpValueForBanc(tLC);
|
---|
221 | }
|
---|
222 | }
|
---|
223 | if (iObs + 1 < OPT->_minObs) {
|
---|
224 | LOG << "t_pppClient::cmpBancroft not enough observations" << endl;
|
---|
225 | return failure;
|
---|
226 | }
|
---|
227 | BB = BB.Rows(1,iObs+1);
|
---|
228 | bancroft(BB, xyzc);
|
---|
229 |
|
---|
230 | xyzc[3] /= t_CST::c;
|
---|
231 |
|
---|
232 | // Check Blunders
|
---|
233 | // --------------
|
---|
234 | const double BLUNDER = 100.0;
|
---|
235 | double maxRes = 0.0;
|
---|
236 | unsigned maxResIndex = 0;
|
---|
237 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
238 | const t_satObs* satObs = obsVector.at(ii);
|
---|
239 | if ( satObs->isValid() && satObs->prn().system() == 'G' &&
|
---|
240 | (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) {
|
---|
241 | ColumnVector rr = satObs->xc().Rows(1,3) - xyzc.Rows(1,3);
|
---|
242 | double res = rr.norm_Frobenius() - satObs->obsValue(tLC)
|
---|
243 | - (satObs->xc()[3] - xyzc[3]) * t_CST::c;
|
---|
244 | if (fabs(res) > maxRes) {
|
---|
245 | maxRes = fabs(res);
|
---|
246 | maxResIndex = ii;
|
---|
247 | }
|
---|
248 | }
|
---|
249 | }
|
---|
250 | if (maxRes < BLUNDER) {
|
---|
251 | if (print) {
|
---|
252 | LOG.setf(ios::fixed);
|
---|
253 | LOG << string(epoTime) << " BANCROFT:" << ' '
|
---|
254 | << setw(14) << setprecision(3) << xyzc[0] << ' '
|
---|
255 | << setw(14) << setprecision(3) << xyzc[1] << ' '
|
---|
256 | << setw(14) << setprecision(3) << xyzc[2] << ' '
|
---|
257 | << setw(14) << setprecision(3) << xyzc[3] * t_CST::c << endl << endl;
|
---|
258 | }
|
---|
259 | break;
|
---|
260 | }
|
---|
261 | else {
|
---|
262 | t_satObs* satObs = obsVector.at(maxResIndex);
|
---|
263 | LOG << "t_pppClient::cmpBancroft outlier " << satObs->prn().toString()
|
---|
264 | << " " << maxRes << endl;
|
---|
265 | delete satObs;
|
---|
266 | obsVector.erase(obsVector.begin() + maxResIndex);
|
---|
267 | }
|
---|
268 | }
|
---|
269 |
|
---|
270 | return success;
|
---|
271 | }
|
---|
272 |
|
---|
273 | // Compute A Priori GPS-Glonass Offset
|
---|
274 | //////////////////////////////////////////////////////////////////////////////
|
---|
275 | double t_pppClient::cmpOffGG(vector<t_satObs*>& obsVector) {
|
---|
276 |
|
---|
277 | t_lc::type tLC = (OPT->dualFreqRequired() ? t_lc::cIF : t_lc::c1);
|
---|
278 | double offGG = 0.0;
|
---|
279 |
|
---|
280 | if (OPT->useGlonass()) {
|
---|
281 | while (true) {
|
---|
282 | offGG = 0.0;
|
---|
283 | bool outlierFound = false;
|
---|
284 | unsigned nObs = 0;
|
---|
285 | for (unsigned ii = 0; ii < obsVector.size(); ii++) {
|
---|
286 | t_satObs* satObs = obsVector.at(ii);
|
---|
287 | if ( !satObs->outlier() && satObs->isValid() && satObs->prn().system() == 'R' &&
|
---|
288 | (!satObs->modelSet() || satObs->eleSat() >= OPT->_minEle) ) {
|
---|
289 | ++nObs;
|
---|
290 | double ll = satObs->obsValue(tLC) - satObs->cmpValue(tLC);
|
---|
291 | if (fabs(ll) > 1000.0) {
|
---|
292 | satObs->setOutlier();
|
---|
293 | outlierFound = true;
|
---|
294 | LOG << "t_pppClient::cmpOffGG outlier " << satObs->prn().toString()
|
---|
295 | << " " << ll << endl;
|
---|
296 | }
|
---|
297 | offGG += ll;
|
---|
298 | }
|
---|
299 | }
|
---|
300 | if (nObs > 0) {
|
---|
301 | offGG = offGG / nObs;
|
---|
302 | }
|
---|
303 | else {
|
---|
304 | offGG = 0.0;
|
---|
305 | }
|
---|
306 | if (!outlierFound) {
|
---|
307 | break;
|
---|
308 | }
|
---|
309 | }
|
---|
310 | }
|
---|
311 |
|
---|
312 | return offGG;
|
---|
313 | }
|
---|
314 |
|
---|
315 | //
|
---|
316 | //////////////////////////////////////////////////////////////////////////////
|
---|
317 | void t_pppClient::initOutput(t_output* output) {
|
---|
318 | _output = output;
|
---|
319 | _output->_numSat = 0;
|
---|
320 | _output->_pDop = 0.0;
|
---|
321 | _output->_error = false;
|
---|
322 | }
|
---|
323 |
|
---|
324 | //
|
---|
325 | //////////////////////////////////////////////////////////////////////////////
|
---|
326 | void t_pppClient::clearObs() {
|
---|
327 | for (unsigned ii = 0; ii < _obsRover.size(); ii++) {
|
---|
328 | delete _obsRover.at(ii);
|
---|
329 | }
|
---|
330 | _obsRover.clear();
|
---|
331 | }
|
---|
332 |
|
---|
333 | //
|
---|
334 | //////////////////////////////////////////////////////////////////////////////
|
---|
335 | void t_pppClient::finish(t_irc irc) {
|
---|
336 |
|
---|
337 | clearObs();
|
---|
338 |
|
---|
339 | _output->_epoTime = _epoTimeRover;
|
---|
340 |
|
---|
341 | if (irc == success) {
|
---|
342 | _output->_xyzRover[0] = _staRover->xyzApr()[0] + _filter->x()[0];
|
---|
343 | _output->_xyzRover[1] = _staRover->xyzApr()[1] + _filter->x()[1];
|
---|
344 | _output->_xyzRover[2] = _staRover->xyzApr()[2] + _filter->x()[2];
|
---|
345 | copy(&_filter->Q().data()[0], &_filter->Q().data()[6], _output->_covMatrix);
|
---|
346 | _output->_numSat = _filter->numSat();
|
---|
347 | _output->_pDop = _filter->PDOP();
|
---|
348 | _output->_error = false;
|
---|
349 | }
|
---|
350 | else {
|
---|
351 | _output->_error = true;
|
---|
352 | }
|
---|
353 | _output->_log = _log->str();
|
---|
354 | delete _log; _log = new ostringstream();
|
---|
355 | }
|
---|
356 |
|
---|
357 | //
|
---|
358 | //////////////////////////////////////////////////////////////////////////////
|
---|
359 | t_irc t_pppClient::cmpModel(t_station* station, const ColumnVector& xyzc,
|
---|
360 | vector<t_satObs*>& obsVector) {
|
---|
361 |
|
---|
362 | bncTime time;
|
---|
363 | time = _epoTimeRover;
|
---|
364 | station->setName(OPT->_roverName);
|
---|
365 | station->setAntName(OPT->_antNameRover);
|
---|
366 | if (OPT->xyzAprRoverSet()) {
|
---|
367 | station->setXyzApr(OPT->_xyzAprRover);
|
---|
368 | }
|
---|
369 | else {
|
---|
370 | station->setXyzApr(xyzc.Rows(1,3));
|
---|
371 | }
|
---|
372 | station->setNeuEcc(OPT->_neuEccRover);
|
---|
373 |
|
---|
374 | // Receiver Clock
|
---|
375 | // --------------
|
---|
376 | station->setDClk(xyzc[3]);
|
---|
377 |
|
---|
378 | // US Restriction
|
---|
379 | // --------------
|
---|
380 | station->checkRestriction(time);
|
---|
381 |
|
---|
382 | // Tides
|
---|
383 | // -----
|
---|
384 | ColumnVector hlp = station->xyzApr();
|
---|
385 | tides(time, hlp);
|
---|
386 | station->setTideDspl(hlp - station->xyzApr());
|
---|
387 |
|
---|
388 | // Observation model
|
---|
389 | // -----------------
|
---|
390 | vector<t_satObs*>::iterator it = obsVector.begin();
|
---|
391 | while (it != obsVector.end()) {
|
---|
392 | t_satObs* satObs = *it;
|
---|
393 | satObs->cmpModel(station);
|
---|
394 | if (satObs->isValid() && satObs->eleSat() >= OPT->_minEle) {
|
---|
395 | ++it;
|
---|
396 | }
|
---|
397 | else {
|
---|
398 | delete satObs;
|
---|
399 | it = obsVector.erase(it);
|
---|
400 | }
|
---|
401 | }
|
---|
402 |
|
---|
403 | return success;
|
---|
404 | }
|
---|
405 |
|
---|
406 | //
|
---|
407 | //////////////////////////////////////////////////////////////////////////////
|
---|
408 | void t_pppClient::processEpoch(int numSatRover, const t_pppSatObs* satObsRover,
|
---|
409 | t_output* output) {
|
---|
410 |
|
---|
411 | try {
|
---|
412 | initOutput(output);
|
---|
413 |
|
---|
414 | // Prepare Observations of the Rover
|
---|
415 | // ---------------------------------
|
---|
416 | if (prepareObs(numSatRover, satObsRover, _obsRover,
|
---|
417 | _epoTimeRover) != success) {
|
---|
418 | return finish(failure);
|
---|
419 | }
|
---|
420 |
|
---|
421 | LOG << "\nResults of Epoch ";
|
---|
422 | if (!_epoTimeRover.undef()) LOG << string(_epoTimeRover);
|
---|
423 | LOG << "\n--------------------------------------\n";
|
---|
424 |
|
---|
425 | for (int iter = 1; iter <= 2; iter++) {
|
---|
426 | ColumnVector xyzc(4); xyzc = 0.0;
|
---|
427 | bool print = (iter == 2);
|
---|
428 | if (cmpBancroft(_epoTimeRover, _obsRover, xyzc, print) != success) {
|
---|
429 | return finish(failure);
|
---|
430 | }
|
---|
431 | if (cmpModel(_staRover, xyzc, _obsRover) != success) {
|
---|
432 | return finish(failure);
|
---|
433 | }
|
---|
434 | }
|
---|
435 |
|
---|
436 | _offGG = cmpOffGG(_obsRover);
|
---|
437 |
|
---|
438 | // Store last epoch of data
|
---|
439 | // ------------------------
|
---|
440 | _obsPool->putEpoch(_epoTimeRover, _obsRover);
|
---|
441 |
|
---|
442 | // Process Epoch in Filter
|
---|
443 | // -----------------------
|
---|
444 | if (_filter->processEpoch(_obsPool) != success) {
|
---|
445 | return finish(failure);
|
---|
446 | }
|
---|
447 | }
|
---|
448 | catch (Exception& exc) {
|
---|
449 | LOG << exc.what() << endl;
|
---|
450 | return finish(failure);
|
---|
451 | }
|
---|
452 | catch (string& msg) {
|
---|
453 | LOG << "Exception: " << msg << endl;
|
---|
454 | return finish(failure);
|
---|
455 | }
|
---|
456 | catch (logic_error exc) {
|
---|
457 | LOG << exc.what() << endl;
|
---|
458 | return finish(failure);
|
---|
459 | }
|
---|
460 | catch (const char* msg) {
|
---|
461 | LOG << msg << endl;
|
---|
462 | return finish(failure);
|
---|
463 | }
|
---|
464 | catch (...) {
|
---|
465 | LOG << "unknown exception" << endl;
|
---|
466 | return finish(failure);
|
---|
467 | }
|
---|
468 |
|
---|
469 | return finish(success);
|
---|
470 | }
|
---|
471 |
|
---|
472 | //
|
---|
473 | ////////////////////////////////////////////////////////////////////////////
|
---|
474 | double lorentz(const ColumnVector& aa, const ColumnVector& bb) {
|
---|
475 | return aa[0]*bb[0] + aa[1]*bb[1] + aa[2]*bb[2] - aa[3]*bb[3];
|
---|
476 | }
|
---|
477 |
|
---|
478 | //
|
---|
479 | ////////////////////////////////////////////////////////////////////////////
|
---|
480 | void t_pppClient::bancroft(const Matrix& BBpass, ColumnVector& pos) {
|
---|
481 |
|
---|
482 | if (pos.Nrows() != 4) {
|
---|
483 | pos.ReSize(4);
|
---|
484 | }
|
---|
485 | pos = 0.0;
|
---|
486 |
|
---|
487 | for (int iter = 1; iter <= 2; iter++) {
|
---|
488 | Matrix BB = BBpass;
|
---|
489 | int mm = BB.Nrows();
|
---|
490 | for (int ii = 1; ii <= mm; ii++) {
|
---|
491 | double xx = BB(ii,1);
|
---|
492 | double yy = BB(ii,2);
|
---|
493 | double traveltime = 0.072;
|
---|
494 | if (iter > 1) {
|
---|
495 | double zz = BB(ii,3);
|
---|
496 | double rho = sqrt( (xx-pos(1)) * (xx-pos(1)) +
|
---|
497 | (yy-pos(2)) * (yy-pos(2)) +
|
---|
498 | (zz-pos(3)) * (zz-pos(3)) );
|
---|
499 | traveltime = rho / t_CST::c;
|
---|
500 | }
|
---|
501 | double angle = traveltime * t_CST::omega;
|
---|
502 | double cosa = cos(angle);
|
---|
503 | double sina = sin(angle);
|
---|
504 | BB(ii,1) = cosa * xx + sina * yy;
|
---|
505 | BB(ii,2) = -sina * xx + cosa * yy;
|
---|
506 | }
|
---|
507 |
|
---|
508 | Matrix BBB;
|
---|
509 | if (mm > 4) {
|
---|
510 | SymmetricMatrix hlp; hlp << BB.t() * BB;
|
---|
511 | BBB = hlp.i() * BB.t();
|
---|
512 | }
|
---|
513 | else {
|
---|
514 | BBB = BB.i();
|
---|
515 | }
|
---|
516 | ColumnVector ee(mm); ee = 1.0;
|
---|
517 | ColumnVector alpha(mm); alpha = 0.0;
|
---|
518 | for (int ii = 1; ii <= mm; ii++) {
|
---|
519 | alpha(ii) = lorentz(BB.Row(ii).t(),BB.Row(ii).t())/2.0;
|
---|
520 | }
|
---|
521 | ColumnVector BBBe = BBB * ee;
|
---|
522 | ColumnVector BBBalpha = BBB * alpha;
|
---|
523 | double aa = lorentz(BBBe, BBBe);
|
---|
524 | double bb = lorentz(BBBe, BBBalpha)-1;
|
---|
525 | double cc = lorentz(BBBalpha, BBBalpha);
|
---|
526 | double root = sqrt(bb*bb-aa*cc);
|
---|
527 |
|
---|
528 | Matrix hlpPos(4,2);
|
---|
529 | hlpPos.Column(1) = (-bb-root)/aa * BBBe + BBBalpha;
|
---|
530 | hlpPos.Column(2) = (-bb+root)/aa * BBBe + BBBalpha;
|
---|
531 |
|
---|
532 | ColumnVector omc(2);
|
---|
533 | for (int pp = 1; pp <= 2; pp++) {
|
---|
534 | hlpPos(4,pp) = -hlpPos(4,pp);
|
---|
535 | omc(pp) = BB(1,4) -
|
---|
536 | sqrt( (BB(1,1)-hlpPos(1,pp)) * (BB(1,1)-hlpPos(1,pp)) +
|
---|
537 | (BB(1,2)-hlpPos(2,pp)) * (BB(1,2)-hlpPos(2,pp)) +
|
---|
538 | (BB(1,3)-hlpPos(3,pp)) * (BB(1,3)-hlpPos(3,pp)) ) -
|
---|
539 | hlpPos(4,pp);
|
---|
540 | }
|
---|
541 | if ( fabs(omc(1)) > fabs(omc(2)) ) {
|
---|
542 | pos = hlpPos.Column(2);
|
---|
543 | }
|
---|
544 | else {
|
---|
545 | pos = hlpPos.Column(1);
|
---|
546 | }
|
---|
547 | }
|
---|
548 | }
|
---|
549 |
|
---|