25 m_nMaxZenithBins = nMaxZenithBins;
26 m_nMaxAzimuthBins = nMaxAzimuthBins;
42 int nSize = pNodes->size();
44 for (
int n = 0; n < nSize; n++)
80 nIndex1 = getZenithBinIndex(position.
fPhi);
81 nIndex2 = getAzimuthBinIndex(position.
fTheta, position.
fPhi);
83 std::list<int>::iterator iter = m_ppTable[nIndex1][nIndex2].begin();
85 float fMinDistance = FLT_MAX;
89 while (iter != m_ppTable[nIndex1][nIndex2].end())
93 if (fDistance < fMinDistance)
95 fMinDistance = fDistance;
103 float fMinPhi, fMaxPhi, fMinTheta, fMaxTheta;
105 float fTestValues[4];
108 getBinMinMaxValues(nIndex1, nIndex2, fMinPhi, fMaxPhi, fMinTheta, fMaxTheta);
112 fTestValues[0] = std::fabs(fMinPhi - position.
fPhi) *
M_PI / 180.0f;
113 fTestValues[1] = std::fabs(fMaxPhi - position.
fPhi) *
M_PI / 180.0f;
114 fTestValues[2] = std::fabs(fMinTheta - position.
fTheta) *
M_PI / 180.0f;
115 fTestValues[3] = std::fabs(fMaxTheta - position.
fTheta) *
M_PI / 180.0f;
121 for (
float fTestValue : fTestValues)
123 if (fTestValue < fMinDistance)
133 CGraphLookupTable::reset()
137 for (
int z = 0; z < getNumberZenithBins(); z++)
139 fZenith = 180.0f / m_nMaxZenithBins * z;
141 for (
int a = 0;
a < getNumberAzimuthBins(fZenith);
a++)
143 m_ppTable[z][
a].clear();
152 CGraphLookupTable::addEntry(
TSphereCoord position,
int nIndex)
154 int nIndex1, nIndex2;
155 nIndex1 = getZenithBinIndex(position.
fPhi);
156 nIndex2 = getAzimuthBinIndex(position.
fTheta, position.
fPhi);
158 m_ppTable[nIndex1][nIndex2].push_back(nIndex);
162 CGraphLookupTable::buildMemory()
166 m_ppTable =
new std::list<int>*[m_nMaxZenithBins];
168 for (
int z = 0; z < m_nMaxZenithBins; z++)
170 fZenith = 180.0f / m_nMaxZenithBins * z;
171 m_ppTable[z] =
new std::list<int>[getNumberAzimuthBins(fZenith)];
176 CGraphLookupTable::cleanMemory()
178 for (
int z = 0; z < m_nMaxZenithBins; z++)
180 delete[] m_ppTable[z];
187 CGraphLookupTable::getNumberZenithBins()
189 return m_nMaxZenithBins;
193 CGraphLookupTable::getNumberAzimuthBins(
float fZenith)
195 int nZenithBin = getZenithBinIndex(fZenith);
202 if (getNumberZenithBins() > 1)
204 fNumberBins = sin(
float(nZenithBin) / (getNumberZenithBins() - 1) *
M_PI) *
205 (m_nMaxAzimuthBins - nMinBins) +
213 return int(fNumberBins + 0.5f);
217 CGraphLookupTable::getAzimuthBinIndex(
float fAzimuth,
float fZenith)
219 float fBinIndex = fAzimuth / 360.0f * (getNumberAzimuthBins(fZenith) - 1) + 0.5f;
220 return int(fBinIndex);
224 CGraphLookupTable::getZenithBinIndex(
float fZenith)
226 float fBinIndex = fZenith / 180.0f * (m_nMaxZenithBins - 1) + 0.5f;
227 return int(fBinIndex);
231 CGraphLookupTable::getBinMinMaxValues(
int nZenithBinIndex,
232 int nAzimuthBinIndex,
238 if ((m_nMaxZenithBins - 1) == 0)
240 fMinZenith = -FLT_MAX;
241 fMaxZenith = FLT_MAX;
245 fMinZenith = (nZenithBinIndex - 0.5f) * 180.0f / (m_nMaxZenithBins - 1);
246 fMaxZenith = (nZenithBinIndex + 0.5f) * 180.0f / (m_nMaxZenithBins - 1);
249 if ((getNumberAzimuthBins((fMinZenith + fMaxZenith) / 2.0f) - 1) == 0)
251 fMinAzimuth = -FLT_MAX;
252 fMaxAzimuth = FLT_MAX;
256 fMinAzimuth = (nAzimuthBinIndex - 0.5f) * 360.0f /
257 (getNumberAzimuthBins((fMinZenith + fMaxZenith) / 2.0f) - 1);
258 fMaxAzimuth = (nAzimuthBinIndex + 0.5f) * 360.0f /
259 (getNumberAzimuthBins((fMinZenith + fMaxZenith) / 2.0f) - 1);