MCPcopy Create free account
hub / github.com/MrKepzie/Natron / findPointInside

Function findPointInside

Engine/CoonsRegularization.cpp:895–936  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

regularizeMethod · 0.85

Calls 7

dirVectFunction · 0.85
findIntersectionFunction · 0.85
emptyMethod · 0.80
getPositionAtTimeMethod · 0.80
ViewIdxClass · 0.70
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected