Commit 83c3121c14e0f5d78a87ba843a9c5843adfff24b
1 parent
90f83371
NaN value for |AxB| > 1 in some cases
Showing
3 changed files
with
10 additions
and
5 deletions
Show diff stats
stim/biomodels/centerline.h
... | ... | @@ -25,7 +25,10 @@ protected: |
25 | 25 | if (i == size() - 1) return at(size() - 1) - at(size() - 2); //the last direction vector is oriented towards the last line segment |
26 | 26 | |
27 | 27 | //all other direction vectors are the average direction of the two joined line segments |
28 | - return ((at(i) - at(i - 1)).norm() + (at(i + 1) - at(i)).norm()).norm(); | |
28 | + vec3<T> a = at(i) - at(i - 1); | |
29 | + vec3<T> b = at(i + 1) - at(i); | |
30 | + vec3<T> ab = a.norm() + b.norm(); | |
31 | + return ab.norm(); | |
29 | 32 | } |
30 | 33 | //initializes the integrated length vector to make parameterization easier, starting with index idx (all previous indices are assumed to be correct) |
31 | 34 | void update_L(size_t start = 0) { | ... | ... |
stim/math/plane.h
stim/math/quaternion.h
... | ... | @@ -46,7 +46,9 @@ public: |
46 | 46 | from = from.norm(); |
47 | 47 | to = to.norm(); |
48 | 48 | vec3<T> r = from.cross(to); //compute the rotation vector |
49 | - T theta = asin(r.len()); //compute the angle of the rotation about r | |
49 | + T l = r.len(); | |
50 | + if (l > 1) l = 1; //we have seen degenerate cases where |r| > 1 (probably due to loss of precision in the cross product) | |
51 | + T theta = asin(l); //compute the angle of the rotation about r | |
50 | 52 | //deal with a zero vector (both k and kn point in the same direction) |
51 | 53 | if(theta == (T)0){ |
52 | 54 | return; | ... | ... |