| 246 | } |
| 247 | |
| 248 | Polygon Polygon::fromCircle(const Position center, const double radius, |
| 249 | const int nVertices) |
| 250 | { |
| 251 | Eigen::Vector2d centerToVertex(radius, 0.0), centerToVertexTemp; |
| 252 | |
| 253 | Polygon polygon; |
| 254 | for (int j = 0; j < nVertices; j++) { |
| 255 | double theta = j * 2 * M_PI / (nVertices - 1); |
| 256 | Eigen::Rotation2D<double> rot2d(theta); |
| 257 | centerToVertexTemp = rot2d.toRotationMatrix() * centerToVertex; |
| 258 | polygon.addVertex(center + centerToVertexTemp); |
| 259 | } |
| 260 | return polygon; |
| 261 | } |
| 262 | |
| 263 | Polygon Polygon::convexHullOfTwoCircles(const Position center1, |
| 264 | const Position center2, const double radius, |