| 894 | } |
| 895 | |
| 896 | static |
| 897 | Point |
| 898 | findPointInside(const BezierCPs& cps, |
| 899 | double time) |
| 900 | { |
| 901 | /* |
| 902 | Given a simple polygon, find some point inside it. Here is a method based on the proof that |
| 903 | there exists an internal diagonal, in [O'Rourke, 13-14]. The idea is that the midpoint of |
| 904 | a diagonal is interior to the polygon. |
| 905 | */ |
| 906 | assert( !cps.empty() ); |
| 907 | int i = 0; |
| 908 | for (BezierCPs::const_iterator it = cps.begin(); it != cps.end(); ++it, ++i) { |
| 909 | Point dir = dirVect(cps, time, i); |
| 910 | if ( (dir.x == 0.) && (dir.y == 0.) ) { |
| 911 | continue; |
| 912 | } |
| 913 | Point p; |
| 914 | (*it)->getPositionAtTime(false, time, ViewIdx(0), &p.x, &p.y); |
| 915 | Point q; |
| 916 | q.x = p.x; |
| 917 | q.y = p.y + dir.y; |
| 918 | BezierCPPtr newPoint; |
| 919 | int beforeIndex = -1; |
| 920 | findIntersection(cps, time, p, q, &newPoint, &beforeIndex); |
| 921 | if ( newPoint && (beforeIndex != -1) ) { |
| 922 | Point np; |
| 923 | newPoint->getPositionAtTime(false, time, ViewIdx(0), &np.x, &np.y); |
| 924 | if ( (np.x != p.x) || (np.y != p.y) ) { |
| 925 | Point m; |
| 926 | m.x = 0.5 * (p.x + np.x); |
| 927 | m.y = 0.5 * (p.y + np.y); |
| 928 | |
| 929 | return m; |
| 930 | } |
| 931 | } |
| 932 | } |
| 933 | Point ret; |
| 934 | cps.front()->getPositionAtTime(false, time, ViewIdx(0), &ret.x, &ret.y); |
| 935 | |
| 936 | return ret; |
| 937 | } |
| 938 | |
| 939 | static double |
| 940 | estimate(int elen, |
no test coverage detected