| 18 | } |
| 19 | |
| 20 | static const VEC Bisector( // return normalized bisector of three ordered points |
| 21 | const VEC& prev, // in: x,y coords of previous point (1x2 matrix) |
| 22 | const VEC& point, // in |
| 23 | const VEC& next) // in |
| 24 | { |
| 25 | VEC u(1, 2); // u is point - prev, rotated by 90 degrees |
| 26 | u(IX) = point(IY) - prev(IY); |
| 27 | u(IY) = prev(IX) - point(IX); |
| 28 | NormalizeMat(u); |
| 29 | |
| 30 | VEC v(1, 2); // v is next - point, rotated by 90 degrees |
| 31 | v(IX) = next(IY) - point(IY); |
| 32 | v(IY) = point(IX) - next(IX); |
| 33 | NormalizeMat(v); |
| 34 | |
| 35 | VEC w(u + v); NormalizeMat(w); |
| 36 | |
| 37 | // are prev and next in the same line? if so, avoid numerical issues |
| 38 | if (IsZero(w(IX)) && IsZero(w(IY))) |
| 39 | { |
| 40 | w = point - prev; |
| 41 | NormalizeMat(w); |
| 42 | } |
| 43 | return w; // w is the direction of the bisector |
| 44 | } |
| 45 | |
| 46 | // get x and y distances to take a single pixel step along the whisker |
| 47 |
no test coverage detected