pixled-lib  1.0
Public Member Functions | List of all members
pixled::mapping::TurtleMapping Class Reference

#include <mapping.h>

Inheritance diagram for pixled::mapping::TurtleMapping:
Inheritance graph
[legend]
Collaboration diagram for pixled::mapping::TurtleMapping:
Collaboration graph
[legend]

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
 

Detailed Description

A turtle graphics based mapping.

Leds are regularly dropped by the "turtle" as it moves in the space.

Member Function Documentation

◆ position()

point pixled::mapping::TurtleMapping::position ( ) const

Current position of the turtle.

◆ orientation()

angle pixled::mapping::TurtleMapping::orientation ( ) const

Current orientation of the turtle.

◆ ledIndex()

index_t pixled::mapping::TurtleMapping::ledIndex ( ) const

Current led index.

◆ forward()

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.

Parameters
distancedistance to cross
num_lednumber of led to drop

◆ turnLeft()

void pixled::mapping::TurtleMapping::turnLeft ( angle  angle)

Turns the turtle left by the specified angle.

Parameters
anglerotation

◆ turnRight()

void pixled::mapping::TurtleMapping::turnRight ( angle  angle)

Turns the turtle right by the specified angle.

Parameters
anglerotation

◆ jump()

void pixled::mapping::TurtleMapping::jump ( point  p)

Places the turtle at position p, without dropping any led, keeping the same orientation().

Parameters
ppoint where the turtle should be placed

The documentation for this class was generated from the following files: