Iterates over all of the valid indexes that lie within a circle from the center out. More...
#include <spiral.h>
Public Member Functions | |
Spiral & | operator= (const Spiral &other) |
Assignment Operator Required to ensure unique_ptr is set properly. | |
Spiral (const nav_grid::NavGridInfo *info, double center_x, double center_y, double radius) | |
Public Constructor. | |
Spiral (const Spiral &other) | |
Copy Constructor Required to ensure unique_ptr is set properly. | |
Standard BaseIterator Interface | |
Spiral | begin () const override |
Helper function for range-style iteration Equivalent to the above constructor. | |
Spiral | end () const override |
Helper function for range-style iteration. | |
void | increment () override |
Increase the iterator to the next element. | |
bool | fieldsEqual (const Spiral &other) override |
Additional check for whether fields of derived iterators are equal. | |
Protected Member Functions | |
bool | isInside (unsigned int x, unsigned int y) const |
Check if the center of the given index is within the circle. | |
void | loadRing () |
Given a new distance value, loads the internal iterator. If there are no valid values in the internal iterator, increases the distance. | |
Spiral (const nav_grid::NavGridInfo *info, const nav_grid::Index &index, double center_x, double center_y, double radius_sq, unsigned int distance, unsigned int max_distance, const nav_grid::Index &start_index) | |
Protected constructor that takes in an arbitrary index and other internal parameters. | |
Protected Attributes | |
double | center_x_ |
double | center_y_ |
unsigned int | distance_ |
std::unique_ptr< CircleOutline > | internal_iterator_ |
unsigned int | max_distance_ |
double | radius_sq_ |
nav_grid::Index | start_index_ |
Iterates over all of the valid indexes that lie within a circle from the center out.
nav_grid_iterators::Spiral::Spiral | ( | const nav_grid::NavGridInfo * | info, |
double | center_x, | ||
double | center_y, | ||
double | radius | ||
) |
Public Constructor.
info | NavGridInfo for the grid to iterate over |
center_x | Center of the circle (x coordinate) |
center_y | Center of the circle (y coordinate) |
radius | Size of the circle |
Definition at line 40 of file spiral.cpp.
nav_grid_iterators::Spiral::Spiral | ( | const Spiral & | other | ) |
Copy Constructor Required to ensure unique_ptr is set properly.
Definition at line 50 of file spiral.cpp.
nav_grid_iterators::Spiral::Spiral | ( | const nav_grid::NavGridInfo * | info, |
const nav_grid::Index & | index, | ||
double | center_x, | ||
double | center_y, | ||
double | radius_sq, | ||
unsigned int | distance, | ||
unsigned int | max_distance, | ||
const nav_grid::Index & | start_index | ||
) | [protected] |
Protected constructor that takes in an arbitrary index and other internal parameters.
info | NavGridInfo for the grid to iterate over |
index | Initial index |
center_x | Center of the circle (x coordinate) |
center_y | Center of the circle (y coordinate) |
radius_sq | Square of the size of the circle |
distance | Which ring of the spiral to start on |
max_distance | The maximum valid ring |
start_index | The first valid index in the spiral |
Definition at line 56 of file spiral.cpp.
Spiral nav_grid_iterators::Spiral::begin | ( | ) | const [override, virtual] |
Helper function for range-style iteration Equivalent to the above constructor.
Implements nav_grid_iterators::BaseIterator< Spiral >.
Definition at line 89 of file spiral.cpp.
Spiral nav_grid_iterators::Spiral::end | ( | ) | const [override, virtual] |
Helper function for range-style iteration.
Implements nav_grid_iterators::BaseIterator< Spiral >.
Definition at line 94 of file spiral.cpp.
bool nav_grid_iterators::Spiral::fieldsEqual | ( | const Spiral & | other | ) | [override, virtual] |
Additional check for whether fields of derived iterators are equal.
Helps make overriding the == operator easy.
Reimplemented from nav_grid_iterators::BaseIterator< Spiral >.
Definition at line 127 of file spiral.cpp.
void nav_grid_iterators::Spiral::increment | ( | ) | [override, virtual] |
Increase the iterator to the next element.
Implements nav_grid_iterators::BaseIterator< Spiral >.
Definition at line 100 of file spiral.cpp.
bool nav_grid_iterators::Spiral::isInside | ( | unsigned int | x, |
unsigned int | y | ||
) | const [protected] |
Check if the center of the given index is within the circle.
Definition at line 145 of file spiral.cpp.
void nav_grid_iterators::Spiral::loadRing | ( | ) | [protected] |
Given a new distance value, loads the internal iterator. If there are no valid values in the internal iterator, increases the distance.
Definition at line 133 of file spiral.cpp.
Assignment Operator Required to ensure unique_ptr is set properly.
Definition at line 70 of file spiral.cpp.
double nav_grid_iterators::Spiral::center_x_ [protected] |
double nav_grid_iterators::Spiral::center_y_ [protected] |
unsigned int nav_grid_iterators::Spiral::distance_ [protected] |
std::unique_ptr<CircleOutline> nav_grid_iterators::Spiral::internal_iterator_ [protected] |
unsigned int nav_grid_iterators::Spiral::max_distance_ [protected] |
double nav_grid_iterators::Spiral::radius_sq_ [protected] |
nav_grid::Index nav_grid_iterators::Spiral::start_index_ [protected] |