Elaboradar  0.1
volume.cpp
1 #include "volume.h"
2 #include "logging.h"
3 #include <stdexcept>
4 #include <algorithm>
5 
6 static const double ker = 8494666.666667; // c'è qualcosa in geo_par.h
7 
8 using namespace std;
9 
10 namespace radarelab {
11 
12 PolarScanBase::PolarScanBase(unsigned beam_count, unsigned beam_size)
13  : beam_count(beam_count), beam_size(beam_size),
14  azimuths_real(beam_count), elevations_real(beam_count)
15 {
16 }
17 
18 PolarScanBase::PolarScanBase(const PolarScanBase& s)
19  : beam_count(s.beam_count), beam_size(s.beam_size),
20  azimuths_real(s.azimuths_real),
21  elevation(s.elevation),
22  elevations_real(s.elevations_real),
23  cell_size(s.cell_size)
24 {
25 }
26 
27 double PolarScanBase::height(unsigned rg, double beam_half_width)
28 {
29  return sample_height(elevation + beam_half_width, (double)rg*cell_size) / 1000.; // km
30 }
31 
32 double PolarScanBase::diff_height(unsigned rg_start, unsigned rg_end)
33 {
34  return fabs(height(rg_end) - height(rg_start));
35 }
36 
37 double PolarScanBase::sample_height(unsigned cell_idx) const
38 {
39  return sample_height(elevation, (double)cell_idx * cell_size);
40 }
41 
42 double PolarScanBase::sample_height(double elevation, double range, double equiv_earth_radius)
43 {
44  return sqrt(
45  range * range
46  + equiv_earth_radius * equiv_earth_radius
47  + 2. * equiv_earth_radius * range * sin(elevation * M_PI / 180.)
48  ) - equiv_earth_radius; //meters
49 }
50 
51 double PolarScanBase::sample_height(double elevation, double range)
52 {
53  return sample_height(elevation, range, ker);
54 }
55 
56 void VolumeStats::print(FILE* out)
57 {
58  fprintf(out, "Nel Zeros Ones Others Sum\n");
59  for (size_t iel =0; iel<count_zeros.size(); ++iel){
60  fprintf(out, "%4zu %8u %8u %8u %8u\n",iel,count_zeros[iel],count_ones[iel],count_others[iel],sum_others[iel]);
61  }
62 }
63 
64 template class PolarScan<double>;
65 template class Volume<double>;
66 
67 namespace volume {
68 template class Scans<double>;
69 }
70 
71 }
String functions.
Definition: cart.cpp:4
Definisce le principali strutture che contengono i dati.