24 #include <fvmodels/scanlines/radial.h> 26 #include <utils/system/console_colors.h> 60 unsigned int center_x,
unsigned int center_y,
61 unsigned int radius_increment,
63 unsigned int max_radius,
unsigned int dead_radius
67 this->height = height;
68 this->center_x = center_x;
69 this->center_y = center_y;
70 this->radius_increment = radius_increment;
72 this->dead_radius = dead_radius;
73 this->max_radius = max_radius;
74 this->auto_max_radius = (max_radius == 0);
95 if ( done )
return &coord;
104 if ( current_radius == 0 ) {
106 current_radius += radius_increment;
163 y = (int)(sqrt( (
float(current_radius * current_radius) -
float(x * x)) ) + 0.5);
171 current_radius += radius_increment;
175 if (current_radius >= max_radius) { done =
true; ok =
true; }
185 if ( (tmp_x < -(
int)center_x) ||
186 (tmp_x > (int)(width - center_x)) ||
187 (tmp_y < -(
int)center_y) ||
188 (tmp_y > (
int)(height - center_y))
196 coord.
x = center_x + tmp_x;
197 coord.
y = center_y + tmp_y;
208 memcpy(&tmp_coord, &coord,
sizeof(
upoint_t));
223 ScanlineRadial::simpleBubbleSort(
unsigned int array[],
unsigned int num_elements)
225 bool modified =
false;
226 unsigned int end = num_elements;
231 for (
unsigned int i = 0; i < end-1; ++i) {
232 if ( array[i] < array[i+1] ) {
234 array[i] = array[i+1];
241 }
while ( modified );
247 current_radius = radius_increment;
248 while (current_radius < dead_radius) {
249 current_radius += radius_increment;
258 if ( auto_max_radius ) {
260 unsigned int dists[4];
261 dists[0] = (
unsigned int)sqrt(
float(center_x * center_x) + float(center_y * center_y) );
262 dists[1] = (
unsigned int)sqrt(
float((width - center_x) * (width - center_x)) + float(center_y * center_y) );
263 dists[2] = (
unsigned int)sqrt(
float((width - center_x) * (width - center_x)) + float((height - center_y) * (height - center_y)) );
264 dists[3] = (
unsigned int)sqrt(
float(center_x * center_x) + float((height - center_y) * (height - center_y)) );
267 simpleBubbleSort(dists, 4);
268 max_radius = dists[0] - 1;
273 if (radius_increment > max_radius) {
275 radius_increment = 1;
278 if (dead_radius > max_radius) {
281 current_radius = radius_increment;
289 return "ScanlineModel::Radial";
296 return radius_increment;
309 this->center_x = center_x;
310 this->center_y = center_y;
324 this->max_radius = max_radius;
325 this->dead_radius = dead_radius;
326 this->auto_max_radius = (max_radius == 0);
fawkes::upoint_t operator*()
Get the current coordinate.
fawkes::upoint_t * operator++()
Postfix ++ operator.
unsigned int get_margin()
Get margin around points.
unsigned int y
y coordinate
unsigned int x
x coordinate
void set_radius(unsigned int dead_radius, unsigned int max_radius)
Set new radius.
const char * get_name()
Get name of scanline model.
void set_center(unsigned int center_x, unsigned int center_y)
Set new center point.
bool finished()
Check if all desired points have been processed.
fawkes::upoint_t * operator->()
Get pointer to current point.
Point with cartesian coordinates as unsigned integers.
ScanlineRadial(unsigned int width, unsigned int height, unsigned int center_x, unsigned int center_y, unsigned int radius_increment, unsigned int step, unsigned int max_radius=0, unsigned int dead_radius=0)
Constructor.