Zie*_*ezi 1 c++ algorithm math computational-geometry
我有一个工作类,可以生成给定的正多边形:多边形中心、多边形半径和边数。两个私有成员函数的实现细节见这里。
类接口如下所示:
class RegularPolygon: public Closed_polyline{
public:
RegularPolygon(Point c, int r, int n)
: center(c), radius(r), sidesNumber(n)
{ generatePoly(); }
private:
Point center;
int radius;
int sidesNumber;
void generatePoly();
void rotateCoordinate(Point& axisOfRotation, Point& initial,
double angRads, int numberOfRotations);
};
Run Code Online (Sandbox Code Playgroud)
我被要求实现使用一组坐标1生成正多边形的第二种方法。构造函数首先需要对传递的坐标执行有效性检查:
RegularPolygon(vector<Point>& vertices)
:center(), radius(), sideNumber()
{
// validity check of the elements of vertices
}
Run Code Online (Sandbox Code Playgroud)
我最初的想法是:
检查[1]以及所有有关生成坐标的问题和答案后。我没有找到我要寻找的东西。
1 按顺时针顺序,传递向量:vertices
归档时间: |
|
查看次数: |
2651 次 |
最近记录: |