import math


def angle(p1, p2, previous=0):
    """
    Calculates the angle between two points.

    :param p1, p2: points
    :param previous: previous angle
    :return: angle
    """
    p1x, p1y = p1
    p2x, p2y = p2

    return (math.atan2(p1y - p2y, p1x - p2x) - previous) % (math.pi * 2) - math.pi