Commit 1b2858a2ead341fc2d7517e55b0318af497ee6a8
1 parent
bb29dc49
fixed some comments in cylinder and network
Showing
2 changed files
with
15 additions
and
14 deletions
Show diff stats
stim/biomodels/network.h
... | ... | @@ -205,7 +205,8 @@ public: |
205 | 205 | |
206 | 206 | // Returns an average of fiber/edge lengths in the network |
207 | 207 | double Lengths(){ |
208 | - stim::vec<T> L;double sumLength = 0; | |
208 | + stim::vec<T> L; | |
209 | + double sumLength = 0; | |
209 | 210 | for(unsigned e = 0; e < E.size(); e++){ //for each edge in the network |
210 | 211 | L.push_back(E[e].length()); //append the edge length |
211 | 212 | sumLength = sumLength + E[e].length(); | ... | ... |
stim/visualization/cylinder.h
... | ... | @@ -64,9 +64,9 @@ class cylinder |
64 | 64 | return; |
65 | 65 | |
66 | 66 | //calculate each L. |
67 | - L.resize(inP.size()); | |
68 | - T temp = (T)0; | |
69 | - L[0] = 0; | |
67 | + L.resize(inP.size()); //the number of precomputed lengths will equal the number of points | |
68 | + T temp = (T)0; //length up to that point | |
69 | + L[0] = temp; | |
70 | 70 | for(size_t i = 1; i < L.size(); i++) |
71 | 71 | { |
72 | 72 | temp += (inP[i-1] - inP[i]).len(); |
... | ... | @@ -479,30 +479,30 @@ class cylinder |
479 | 479 | |
480 | 480 | std::vector< vec3<T> > result; |
481 | 481 | |
482 | - vec3<T> p0 = e[0].P; //initialize p0 to the first point on the centerline | |
482 | + vec3<T> p0 = e[0].P; //initialize p0 to the first point on the centerline | |
483 | 483 | vec3<T> p1; |
484 | - unsigned N = size(); //number of points in the current centerline | |
484 | + unsigned N = size(); //number of points in the current centerline | |
485 | 485 | |
486 | 486 | //for each line segment on the centerline |
487 | 487 | for(unsigned int i = 1; i < N; i++){ |
488 | - p1 = e[i].P; //get the second point in the line segment | |
488 | + p1 = e[i].P; //get the second point in the line segment | |
489 | 489 | |
490 | - vec3<T> v = p1 - p0; //calculate the vector between these two points | |
491 | - T d = v.len(); //calculate the distance between these two points (length of the line segment) | |
490 | + vec3<T> v = p1 - p0; //calculate the vector between these two points | |
491 | + T d = v.len(); //calculate the distance between these two points (length of the line segment) | |
492 | 492 | |
493 | 493 | size_t nsteps = (size_t)std::ceil(d / spacing); //calculate the number of steps to take along the segment to meet the spacing criteria |
494 | - T stepsize = (T)1.0 / nsteps; //calculate the parametric step size between new centerline points | |
494 | + T stepsize = (T)1.0 / nsteps; //calculate the parametric step size between new centerline points | |
495 | 495 | |
496 | 496 | //for each step along the line segment |
497 | 497 | for(unsigned s = 0; s < nsteps; s++){ |
498 | - T alpha = stepsize * s; //calculate the fraction of the distance along the line segment covered | |
499 | - result.push_back(p0 + alpha * v); //push the point at alpha position along the line segment | |
498 | + T alpha = stepsize * s; //calculate the fraction of the distance along the line segment covered | |
499 | + result.push_back(p0 + alpha * v); //push the point at alpha position along the line segment | |
500 | 500 | } |
501 | 501 | |
502 | - p0 = p1; //shift the points to move to the next line segment | |
502 | + p0 = p1; //shift the points to move to the next line segment | |
503 | 503 | } |
504 | 504 | |
505 | - result.push_back(e[size() - 1].P); //push the last point in the centerline | |
505 | + result.push_back(e[size() - 1].P); //push the last point in the centerline | |
506 | 506 | |
507 | 507 | return cylinder<T>(result); |
508 | 508 | ... | ... |