star polygon {n/step} as a single self-intersecting closed contour (needs gcd(n,step)==1)
| 101 | |
| 102 | // star polygon {n/step} as a single self-intersecting closed contour (needs gcd(n,step)==1) |
| 103 | Contour2d 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 | |
| 117 | template <typename Contours> |
| 118 | size_t countVerts( const Contours& cs ) |