|
pixled-lib
1.0
|
#include <mapping.h>


Public Member Functions | |
| point | position () const |
| angle | orientation () const |
| index_t | ledIndex () const |
| void | forward (coordinate distance, index_t num_led=0) |
| void | turnLeft (angle angle) |
| void | turnRight (angle angle) |
| void | jump (point p) |
Public Member Functions inherited from pixled::Mapping | |
| const std::vector< led > & | leds () const |
| void | push (const led &led) |
| box | boundingBox () const |
A turtle graphics based mapping.
Leds are regularly dropped by the "turtle" as it moves in the space.
| point pixled::mapping::TurtleMapping::position | ( | ) | const |
Current position of the turtle.
| angle pixled::mapping::TurtleMapping::orientation | ( | ) | const |
Current orientation of the turtle.
| index_t pixled::mapping::TurtleMapping::ledIndex | ( | ) | const |
Current led index.
| void pixled::mapping::TurtleMapping::forward | ( | coordinate | distance, |
| index_t | num_led = 0 |
||
| ) |
Moves the turtle distance forward, dropping num_led leds.
Leds are placed to correspond as much as possible to the shape of a real led strip.
For example, we might represent a led on a led strip as follows, including margins: | o |
Now, if we represent the starting and final positions of the turtle by + , the generated mapping would look as follows if 3 leds are placed: + o | o | o +. The positions of the leds correspond to os. The margin between leds is computed to fit the total distance with the provided num_led.
The most important aspect of this mechanism is to understand that the first led is not dropped at the current position of the turtle: it would be more accurate to say that the "input pin" of the led is placed at the current position.
| distance | distance to cross |
| num_led | number of led to drop |
| void pixled::mapping::TurtleMapping::turnLeft | ( | angle | angle | ) |
Turns the turtle left by the specified angle.
| angle | rotation |
| void pixled::mapping::TurtleMapping::turnRight | ( | angle | angle | ) |
Turns the turtle right by the specified angle.
| angle | rotation |
| void pixled::mapping::TurtleMapping::jump | ( | point | p | ) |
Places the turtle at position p, without dropping any led, keeping the same orientation().
| p | point where the turtle should be placed |