118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
|
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
|
+
+
+
+
+
+
+
-
+
|
*/
double length()const;
/**
* Returns the points along the line.
*/
std::vector<Point> getPoints()const;
};
class BoundedConstruct{
public:
/**
* Obtain an area(or as near an estimate as possible)
*/
virtual double getArea()const=0;
};
class Circle:public Shape{
class Circle:public Shape,public BoundedConstruct{
public:
/**
* The center of the circle.
*/
Point thing;
/**
* The radius of the circle (A.K.A the distance between the center and any
|
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
|
-
+
+
-
+
+
|
/**
* Finds the intersection between this circle and this circle.
*/
void intersectionPoint(const Circle& b,int &n,std::vector<Point> &output)const;
/**
* Finds the intersection between the a line and the boundary of the
* circle, faster than the naive Shape.intersectionPoint
*/:w
*/
void intersectionPoint(const Line &b,int &n, std::vector<Point> &output)const;
/**
* Returns true if the point is very nearly on the boundary of the circle
* (EPSILON in this case is 0.005).
* Guaranteed to not modify any parameters or objects.
*/
bool isOnCircle(const Point &i)const;
/**
* Returns true if the point is very nearly on the boundary of the circle,
* within an error specified by the caller.
*
* Guaranteed to not modify parameters or objects.
*/
bool isOnCircle(const Point &i,double error)const;
/**
* Returns an outline of points roughly in the shape of the circumferance
* of the circle
*/
std::vector<Point> getPoints()const;
double getArea()const;
};
class Polygon:public Shape{
class Polygon:public Shape,public BoundedConstruct{
/**
* The points which make up the endpoints of the line segments of the
* polygon.
*/
std::vector<Point> points;
public:
Polygon();
~Polygon();
/**
* Obtains a point cloud roughly in the shape of the polygon.
*/
std::vector<Point> getPoints()const;
/**
* Add a point to end of the polygon(connected to the first point and the
* last point previously specified).
*/
void addPoint(const Point &i);
double getArea()const;
};
#endif
|