MCPcopy Create free account
hub / github.com/MeshInspector/MeshLib / benchStar

Function benchStar

source/MRTest/MR2DContoursTriangulationTests.cpp:103–115  ·  view source on GitHub ↗

star polygon {n/step} as a single self-intersecting closed contour (needs gcd(n,step)==1)

Source from the content-addressed store, hash-verified

101
102// star polygon {n/step} as a single self-intersecting closed contour (needs gcd(n,step)==1)
103Contour2d benchStar( int n, int step, double r, const Vector2d& center )
104{
105 Contour2d cont;
106 cont.reserve( n + 1 );
107 for ( int i = 0; i < n; ++i )
108 {
109 const int idx = ( i * step ) % n;
110 const double a = 2.0 * PI * idx / n;
111 cont.push_back( center + Vector2d( r * std::cos( a ), r * std::sin( a ) ) );
112 }
113 cont.push_back( cont.front() );
114 return cont;
115}
116
117template <typename Contours>
118size_t countVerts( const Contours& cs )

Callers 1

TESTFunction · 0.85

Calls 2

push_backMethod · 0.80
reserveMethod · 0.45

Tested by

no test coverage detected