23 m_nMaxZenithBins = nMaxZenithBins;
24 m_nMaxAzimuthBins = nMaxAzimuthBins;
39 int nSize = pNodes->size();
41 for (
int n = 0 ; n < nSize ; n++)
74 nIndex1 = getZenithBinIndex(position.
fPhi);
75 nIndex2 = getAzimuthBinIndex(position.
fTheta, position.
fPhi);
77 std::list<int>::iterator iter = m_ppTable[nIndex1][nIndex2].begin();
79 float fMinDistance = FLT_MAX;
83 while (iter != m_ppTable[nIndex1][nIndex2].end())
87 if (fDistance < fMinDistance)
89 fMinDistance = fDistance;
97 float fMinPhi, fMaxPhi, fMinTheta, fMaxTheta;
102 getBinMinMaxValues(nIndex1, nIndex2, fMinPhi, fMaxPhi, fMinTheta, fMaxTheta);
106 fTestValues[0] = std::fabs(fMinPhi - position.
fPhi) *
M_PI / 180.0f;
107 fTestValues[1] = std::fabs(fMaxPhi - position.
fPhi) *
M_PI / 180.0f;
108 fTestValues[2] = std::fabs(fMinTheta - position.
fTheta) *
M_PI / 180.0f;
109 fTestValues[3] = std::fabs(fMaxTheta - position.
fTheta) *
M_PI / 180.0f;
115 for (
float fTestValue : fTestValues)
117 if (fTestValue < fMinDistance)
126 void CGraphLookupTable::reset()
130 for (
int z = 0 ; z < getNumberZenithBins() ; z++)
132 fZenith = 180.0f / m_nMaxZenithBins * z;
134 for (
int a = 0 ;
a < getNumberAzimuthBins(fZenith) ;
a++)
136 m_ppTable[z][
a].clear();
144 void CGraphLookupTable::addEntry(
TSphereCoord position,
int nIndex)
146 int nIndex1, nIndex2;
147 nIndex1 = getZenithBinIndex(position.
fPhi);
148 nIndex2 = getAzimuthBinIndex(position.
fTheta, position.
fPhi);
150 m_ppTable[nIndex1][nIndex2].push_back(nIndex);
153 void CGraphLookupTable::buildMemory()
157 m_ppTable =
new std::list<int>* [m_nMaxZenithBins];
159 for (
int z = 0 ; z < m_nMaxZenithBins ; z++)
161 fZenith = 180.0f / m_nMaxZenithBins * z;
162 m_ppTable[z] =
new std::list<int>[getNumberAzimuthBins(fZenith)];
166 void CGraphLookupTable::cleanMemory()
168 for (
int z = 0 ; z < m_nMaxZenithBins ; z++)
170 delete [] m_ppTable[z];
176 int CGraphLookupTable::getNumberZenithBins()
178 return m_nMaxZenithBins;
181 int CGraphLookupTable::getNumberAzimuthBins(
float fZenith)
183 int nZenithBin = getZenithBinIndex(fZenith);
190 if (getNumberZenithBins() > 1)
192 fNumberBins = sin(
float(nZenithBin) / (getNumberZenithBins() - 1) *
M_PI) * (m_nMaxAzimuthBins - nMinBins) + nMinBins;
199 return int(fNumberBins + 0.5f);
202 int CGraphLookupTable::getAzimuthBinIndex(
float fAzimuth,
float fZenith)
204 float fBinIndex = fAzimuth / 360.0f * (getNumberAzimuthBins(fZenith) - 1) + 0.5f;
205 return int(fBinIndex);
208 int CGraphLookupTable::getZenithBinIndex(
float fZenith)
210 float fBinIndex = fZenith / 180.0f * (m_nMaxZenithBins - 1) + 0.5f;
211 return int(fBinIndex);
214 void CGraphLookupTable::getBinMinMaxValues(
int nZenithBinIndex,
int nAzimuthBinIndex,
float& fMinZenith,
float& fMaxZenith,
float& fMinAzimuth,
float& fMaxAzimuth)
216 if ((m_nMaxZenithBins - 1) == 0)
218 fMinZenith = -FLT_MAX;
219 fMaxZenith = FLT_MAX;
223 fMinZenith = (nZenithBinIndex - 0.5f) * 180.0f / (m_nMaxZenithBins - 1);
224 fMaxZenith = (nZenithBinIndex + 0.5f) * 180.0f / (m_nMaxZenithBins - 1);
227 if ((getNumberAzimuthBins((fMinZenith + fMaxZenith) / 2.0f) - 1) == 0)
229 fMinAzimuth = -FLT_MAX;
230 fMaxAzimuth = FLT_MAX;
234 fMinAzimuth = (nAzimuthBinIndex - 0.5f) * 360.0f / (getNumberAzimuthBins((fMinZenith + fMaxZenith) / 2.0f) - 1);
235 fMaxAzimuth = (nAzimuthBinIndex + 0.5f) * 360.0f / (getNumberAzimuthBins((fMinZenith + fMaxZenith) / 2.0f) - 1);