MCPcopy Create free account
hub / github.com/KAlO2/PerfectShow / Bisector

Function Bisector

jni/stasm/classicdesc.cpp:20–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18}
19
20static 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

Callers 1

WhiskerStepFunction · 0.85

Calls 2

NormalizeMatFunction · 0.85
IsZeroFunction · 0.85

Tested by

no test coverage detected