Commit d31531d8f981c1dc3916ed9723a3617de5d41404
1 parent
c9712fb4
fix minor error in computing geometry metric
Showing
1 changed file
with
3 additions
and
3 deletions
Show diff stats
stim/visualization/cylinder.h
... | ... | @@ -178,14 +178,14 @@ public: |
178 | 178 | T sum = 0; //initialize the integral to zero |
179 | 179 | T m0, m1; //allocate space for both magnitudes in a single segment |
180 | 180 | m0 = M[0][m]; //initialize the first point and magnitude to the first point in the cylinder |
181 | - T len = L[0]; //allocate space for the segment length | |
181 | + T len = L[1]; //allocate space for the segment length | |
182 | 182 | |
183 | 183 | |
184 | 184 | for (unsigned p = 1; p < size(); p++) { //for every consecutive point in the cylinder |
185 | 185 | m1 = M[p][m]; |
186 | - if (p > 1) len = (L[p - 1] - L[p - 2]); //calculate the segment length using the L array | |
186 | + if (p > 1) len = (L[p] - L[p - 1]); //calculate the segment length using the L array | |
187 | 187 | sum += (m0 + m1) / (T)2.0 * len; //add the average magnitude, weighted by the segment length |
188 | - m0 = m1; //move to the next segment by shifting points | |
188 | + m0 = m1; //move to the next segment by shifting points | |
189 | 189 | } |
190 | 190 | return sum; //return the integral |
191 | 191 | } | ... | ... |