BamBirds 2021
rebound.state.State Class Reference
Inheritance diagram for rebound.state.State:
Collaboration diagram for rebound.state.State:

Public Member Functions

def __init__ (self, turn, prev, tuple coords, int entry_edge, int mt, list theta_range, float velocity, no_gravity=False)
 
def next_states (self, pixels, shuffle=True)
 
def next_state (self, int exit_edge, pixels)
 
def bounce (self, start_angles, int bounce_edge, wall_angle)
 
def on_line (self)
 
def next_pixel (self, int i)
 
def free (self, pixels, i=None)
 
def hits_target (self, pixels, i=None)
 
np.ndarray point_angle (self, pixels, i=None)
 
def apply_gravity (self, tuple new_coords, int entry_edge, list possible_angle_range)
 
def on_parabola (self, list angles, float velocity)
 
def __str__ (self)
 
def __eq__ (self, value)
 
def show (self)
 
def plot_points (self, plotter)
 
def show_on_image (self, img, color_prev=(None, None, 255), color_to_show=(None, None, 100), image_name="tmp.png")
 
def path_length (self)
 
def better_path_length (self)
 
def actual_path_length (self)
 
def better_actual_path_length (self)
 
def start_angle_range (self)
 
def first_turn (self)
 
def origin (self)
 

Public Attributes

 turn
 
 prev
 
 coords
 
 entry_edge
 
 mt
 
 theta_range
 
 velocity
 
 no_gravity
 

Detailed Description

Defines a state in the simulation

Arguments:
    turn {State} -- Last State where the direction changed because of a bounce.
    prev {State} -- Previous State
    coords {tuple} -- coordinates of the state
    entry_edge {int} -- edge on which the current zone was entered
    mt {int} -- Movement Type. One of settings.[FLY|BOUNCE|SLIDE]
    theta_range {list} -- Angle interval at turn to reach this state
    velocity {float} -- velocity at turn 

Keyword Arguments:
    no_gravity {bool} -- if no gravity, angle, rebound calculations should be executed (default: {False})

Raises:
    TypeError: invalid type for coords, entry_edge or mt

Member Function Documentation

◆ actual_path_length()

def rebound.state.State.actual_path_length (   self)
Path length that is more accurate to the acutal path. uses the distance between edges

Returns:
    float -- length of the path

◆ apply_gravity()

def rebound.state.State.apply_gravity (   self,
tuple  new_coords,
int  entry_edge,
list  possible_angle_range 
)
Apply gravity to the current angle for the new state

Arguments:
    new_coords {tuple} -- Coordinates of the new zone
    entry_edge {int} -- entry edge into the new zone
    possible_angle_range {[type]} -- Possible angle range for the transition over entry edge

Raises:
    ArithmeticError: if there are no possible new angles

Returns:
    tuple -- (new starting angle interval, current angle interval in the new zone)

◆ better_actual_path_length()

def rebound.state.State.better_actual_path_length (   self)
Combination of parabola path length and actual path length if no_gravity is true

Returns:
    float -- length of the path

◆ better_path_length()

def rebound.state.State.better_path_length (   self)
Path length for parabolas. Calculates the distance between turn points

Returns:
    float -- length of the path

◆ bounce()

def rebound.state.State.bounce (   self,
  start_angles,
int  bounce_edge,
  wall_angle 
)
bounce and calculate the angles after a bounce

Arguments:
    start_angles {sequence} -- starting angles at turn
    bounce_edge {int} -- edge of the bounce
    wall_angle {np.ndarray} -- normal for the wall

Returns:
    list -- new angle interval after the bounce

◆ first_turn()

def rebound.state.State.first_turn (   self)
Return the first turn point

Returns:
    State -- first turn point

◆ free()

def rebound.state.State.free (   self,
  pixels,
  i = None 
)
Calculate if the current or next zone is only filled with ABType.Background

Arguments:
    pixels {numpy.ndarray} -- level representation

Keyword Arguments:
    i {int} -- if set the zone at the exit edge i is checked (default: {None})

Returns:
    bool -- if the zone is free

◆ hits_target()

def rebound.state.State.hits_target (   self,
  pixels,
  i = None 
)
Calculate if the corrent or next zone contains hits the target

Arguments:
    pixels {numpy.ndarray} -- level representation

Keyword Arguments:
    i {int} -- if set the zone at the exit edge i is checked (default: {None})

Returns:
    bool -- if the zone hits the target

◆ next_pixel()

def rebound.state.State.next_pixel (   self,
int  i 
)
Calculate the coordinates of the next pixel at exit edge i

Arguments:
    i {int} -- exit edge

Returns:
    tuple -- coordinates of the next pixel

◆ next_state()

def rebound.state.State.next_state (   self,
int  exit_edge,
  pixels 
)
Calculate the a next state

Arguments:
    exit_edge {int} -- edge to exit the current zone
    pixels {numpy.ndarray} -- matrix for representation

Returns:
    State -- the new state in the zon of exit edge

◆ on_parabola()

def rebound.state.State.on_parabola (   self,
list  angles,
float  velocity 
)
Calculate if the previous state are on the parabola

Arguments:
    angles {list} -- starting angles to test
    velocity {float} -- starting velocity

Returns:
    bool -- if the previous states are on the parabola

◆ origin()

def rebound.state.State.origin (   self)
Return the origin of the simulation

Returns:
    State -- origin state

◆ path_length()

def rebound.state.State.path_length (   self)
Primitive path length of the state history. Only considers number of states

Returns:
    int -- length of the path

◆ plot_points()

def rebound.state.State.plot_points (   self,
  plotter 
)
Plot previous state history as points to plotter

Arguments:
    plotter {axis or matplotlib} -- Where to plot the points to

◆ point_angle()

np.ndarray rebound.state.State.point_angle (   self,
  pixels,
  i = None 
)
Calculate the angle of the wall in 

Arguments:
    pixels {numpy.ndarray} -- level representation

Keyword Arguments:
    i {int} -- if set the zone at the exit edge i is checked (default: {None})

Raises:
    ValueError: if there is no object edge in the zone

Returns:
    np.ndarray -- the normal of the edge at the specified zone

◆ show()

def rebound.state.State.show (   self)
Show the State and its previous states in a matplotlib window

will not be executed if settings.image_debug is false

◆ show_on_image()

def rebound.state.State.show_on_image (   self,
  img,
  color_prev = (None,None,255),
  color_to_show = (None,None,100),
  image_name = "tmp.png" 
)
Reveal the state history on an image

Arguments:
    img {Image} -- Image to draw the state history to

Keyword Arguments:
    color_prev {tuple} -- color to restore at the respective pixels (default: {(None,None,255)})
    color_to_show {tuple} -- color to print at the pixels (default: {(None,None,100)})
    image_name {str} -- file to save the image to if settings.save_images is true (default: {"tmp.png"})

◆ start_angle_range()

def rebound.state.State.start_angle_range (   self)
Return the angle interval before the last turn point

Returns:
    list -- angle interval

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