Esempio n. 1
0
def backboards(full_surf=True, rotate=False, rotation_dir='ccw'):
    """
    Generate the dataframe for the points that comprise the backboard as
    specified in Rule 1, Section 10, Article 2 of the NCAA rule book

    Returns
    -------
    backboard: a pandas dataframe of the backboard
    """
    # Per the rule book, the backboard must by 6' wide. The height of the
    # backboard is irrelevant in this graphic, as this is a bird's eye view
    # over the court
    backboard = create.rectangle(x_min=-43 - (4 / 12),
                                 x_max=-43,
                                 y_min=-3,
                                 y_max=3)

    # Reflect the x coordinates over the y axis
    if full_surf:
        backboard = backboard.append(transform.reflect(backboard, over_y=True))

    # Rotate the coordinates if necessary
    if rotate:
        backboard = transform.rotate(backboard, rotation_dir)

    return backboard
Esempio n. 2
0
def division_line(full_surf=True, rotate=False, rotation_dir='ccw'):
    """
    Generate the dataframe for the points that comprise the bounding box of
    the division line as specified in Rule 1, Section 5, Article 1 of the NCAA
    rule book
    
    Parameters
    ----------
    full_surf: a bool indicating whether or not this feature is needed for a
        full-surface representation
    rotate: a bool indicating whether or not this feature needs to be rotated
    rotation_dir: a string indicating which direction to rotate the feature
    
    Returns
    -------
    division_line: A pandas dataframe of the interior boundaries of the court
    """
    # The line's center should be 47' from the interior side of the baselines,
    # and must be 2" thick
    division_line = create.rectangle(x_min=-1 / 12,
                                     x_max=0,
                                     y_min=-25,
                                     y_max=25)

    # Reflect the x coordinates over the y axis
    if full_surf:
        division_line = division_line.append(
            transform.reflect(division_line, over_y=True))

    # Rotate the coordinates if necessary
    if rotate:
        division_line = transform.rotate(division_line, rotation_dir)

    return division_line
Esempio n. 3
0
def painted_areas(full_surf=True, rotate=False, rotation_dir='ccw'):
    """
    Generate the dataframe for the points that comprise the bounding box of the
    free throw lane as specified in Rule 1, Section 6, Articles 1, 2, 3, and 4
    of the NCAA rule book
    
    Parameters
    ----------
    full_surf: a bool indicating whether or not this feature is needed for a
        full-surface representation
    rotate: a bool indicating whether or not this feature needs to be rotated
    rotation_dir: a string indicating which direction to rotate the feature
    
    Returns
    -------
    painted_areas: a pandas dataframe of the painted areas
    """
    # The interior of the free throw lane is known as the painted area, and
    # can be a different color than the markings and court. These coordinates
    # can be used to color them on the plot
    painted_area = create.rectangle(x_min=-47,
                                    xmax=-28 - (2 / 12),
                                    y_min=-6 + (2 / 12),
                                    y_max=6 - (2 / 12))

    # Reflect the x coordinates over the y axis
    if full_surf:
        painted_area = painted_area.append(
            transform.reflect(painted_area, over_y=True))

    # Rotate the coordinates if necessary
    if rotate:
        painted_area = transform.rotate(painted_area, rotation_dir)

    return painted_area
Esempio n. 4
0
def bench_areas(full_surf=True, rotate=False, rotation_dir='ccw'):
    """
    Generate the dataframe for the points that comprise the team bench areas
    as specified on the court diagram in the NCAA rule book
    
    Parameters
    ----------
    full_surf: a bool indicating whether or not this feature is needed for a
        full-surface representation
    rotate: a bool indicating whether or not this feature needs to be rotated
    rotation_dir: a string indicating which direction to rotate the feature
    
    Returns
    -------
    bench_areas: a pandas dataframe of the team bench areas
    """
    # The bench area is 28 feet from the interior of the endline, is 2" wide,
    # and extends 3' on each side of the sideline
    bench_area = create.rectangle(x_min=-19 - (2 / 12),
                                  x_max=-19,
                                  y_min=22,
                                  y_max=28)

    # Reflect the x coordinates over the y axis
    if full_surf:
        bench_area = bench_area.append(
            transform.reflect(bench_area, over_y=True))
    # Rotate the coordinates if necessary
    if rotate:
        bench_area = transform.rotate(bench_area, rotation_dir)

    return bench_area
Esempio n. 5
0
def coaching_boxes(full_surf=True, rotate=False, rotation_dir='ccw'):
    """
    Generate the dataframe for the points that comprise the bounding box of the
    coaching boxes as specified in Rule 1, Section 9, Articles 1 and 2 of the
    NCAA rule book
    
    Parameters
    ----------
    full_surf: a bool indicating whether or not this feature is needed for a
        full-surface representation
    rotate: a bool indicating whether or not this feature needs to be rotated
    rotation_dir: a string indicating which direction to rotate the feature
    
    Returns
    -------
    coaching_boxes: a pandas dataframe of the sidelines
    """
    # The coaching boxes are 38' from the interior of the baseline on each
    # side of the court, and extend 2' out of bounds from the exterior of the
    # sideline
    coaching_box = create.rectangle(x_min=-9 - (2 / 12),
                                    x_max=-9,
                                    y_min=25,
                                    y_max=27)

    # Reflect the x coordinates over the y axis
    if full_surf:
        coaching_box = coaching_box.append(
            transform.reflect(coaching_box, over_y=True))

    # Rotate the coordinates if necessary
    if rotate:
        coaching_box = transform.rotate(coaching_box, rotation_dir)

    return coaching_box
Esempio n. 6
0
def lower_defensive_box_ticks(full_surf=True,
                              rotate=False,
                              rotation_dir='ccw'):
    """
    Generate the dataframe for the points that comprise the bounding box of the
    lower defensive box tick marks as specified in Rule 1, Section 3, Article 7
    of the NCAA rule book (women's only). While it only pertains to women's
    basketball, universities typically only have one court for both teams, so
    this marking appears on the men's floor as well
    
    Parameters
    ----------
    full_surf: a bool indicating whether or not this feature is needed for a
        full-surface representation
    rotate: a bool indicating whether or not this feature needs to be rotated
    rotation_dir: a string indicating which direction to rotate the feature
    
    Returns
    -------
    endline_sideline: a pandas dataframe of the end lines and side lines
    """
    # The defensive box is marked by two 2"-thick tick marks, each being 3'
    # from the edge of the lane and extending 12" into the court
    lower_defensive_box_tick = create.rectangle(x_min=-47,
                                                x_max=-46,
                                                y_min=-9 - (2 / 12),
                                                y_max=-9)

    # Reflect the x coordinates over the y axis
    if full_surf:
        lower_defensive_box_tick = lower_defensive_box_tick.append(
            transform.reflect(lower_defensive_box_tick, over_y=True))

    # Rotate the coordinates if necessary
    if rotate:
        lower_defensive_box_tick = transform.rotate(lower_defensive_box_tick,
                                                    rotation_dir)

    return lower_defensive_box_tick