24#include <fvmodels/scanlines/radial.h>
25#include <utils/system/console_colors.h>
57 unsigned int center_x,
58 unsigned int center_y,
59 unsigned int radius_increment,
61 unsigned int max_radius,
62 unsigned int dead_radius)
65 this->height = height;
66 this->center_x = center_x;
67 this->center_y = center_y;
68 this->radius_increment = radius_increment;
70 this->dead_radius = dead_radius;
71 this->max_radius = max_radius;
72 this->auto_max_radius = (max_radius == 0);
101 if (current_radius == 0) {
103 current_radius += radius_increment;
157 y = (int)(sqrt((
float(current_radius * current_radius) -
float(x * x))) + 0.5);
165 current_radius += radius_increment;
169 if (current_radius >= max_radius) {
181 if ((tmp_x < -(
int)center_x) || (tmp_x > (int)(width - center_x)) || (tmp_y < -(
int)center_y)
182 || (tmp_y > (
int)(height - center_y))) {
189 coord.
x = center_x + tmp_x;
190 coord.
y = center_y + tmp_y;
201 memcpy(&tmp_coord, &coord,
sizeof(
upoint_t));
215ScanlineRadial::simpleBubbleSort(
unsigned int array[],
unsigned int num_elements)
217 bool modified =
false;
218 unsigned int end = num_elements;
223 for (
unsigned int i = 0; i < end - 1; ++i) {
224 if (array[i] < array[i + 1]) {
226 array[i] = array[i + 1];
239 current_radius = radius_increment;
240 while (current_radius < dead_radius) {
241 current_radius += radius_increment;
250 if (auto_max_radius) {
252 unsigned int dists[4];
253 dists[0] = (
unsigned int)sqrt(
float(center_x * center_x) + float(center_y * center_y));
254 dists[1] = (
unsigned int)sqrt(
float((width - center_x) * (width - center_x))
255 + float(center_y * center_y));
256 dists[2] = (
unsigned int)sqrt(
float((width - center_x) * (width - center_x))
257 + float((height - center_y) * (height - center_y)));
258 dists[3] = (
unsigned int)sqrt(
float(center_x * center_x)
259 + float((height - center_y) * (height - center_y)));
262 simpleBubbleSort(dists, 4);
263 max_radius = dists[0] - 1;
268 if (radius_increment > max_radius) {
270 radius_increment = 1;
273 if (dead_radius > max_radius) {
276 current_radius = radius_increment;
283 return "ScanlineModel::Radial";
289 return radius_increment;
301 this->center_x = center_x;
302 this->center_y = center_y;
315 this->max_radius = max_radius;
316 this->dead_radius = dead_radius;
317 this->auto_max_radius = (max_radius == 0);
fawkes::upoint_t * operator->()
Get pointer to current point.
bool finished()
Check if all desired points have been processed.
void set_center(unsigned int center_x, unsigned int center_y)
Set new center point.
const char * get_name()
Get name of scanline model.
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.
unsigned int get_margin()
Get margin around points.
void set_radius(unsigned int dead_radius, unsigned int max_radius)
Set new radius.
fawkes::upoint_t operator*()
Get the current coordinate.
fawkes::upoint_t * operator++()
Postfix ++ operator.
Point with cartesian coordinates as unsigned integers.
unsigned int x
x coordinate
unsigned int y
y coordinate