def vortex_position_in_panel(P1, P2, P3, P4):
    """
    For a given panel defined by points P1, P2, P3 and P4
    returns the position of the horseshoe vortex defined
    by points A, B and its control point P.

            ^
          y |                Points defining the panel
            |                are named clockwise.
     P3--B--|-----P4
      |  |  |     |
      |  |  |     |
     T1  |  +--P--T2---->
      |  |        |     x
      |  |        |
     P2--A--------P1

    Parameters
    ----------
    P1, P2, P3, P4 : array_like
                     Points that define the panel

    Returns
    -------
    [P, A, B] : dict
        P - control point where the boundary condition V*n = 0
            is applied according to the Vortice Lattice Method.
        A, B - points that define the horseshoe position
    """

    P2P1 = P1 - P2
    P3P4 = P4 - P3
    P2P3 = P3 - P2
    P1P4 = P4 - P1

    T1 = P2 + P2P3 / 2
    T2 = P1 + P1P4 / 2
    T1T2 = T2 - T1

    A = P2 + P2P1 / 4
    B = P3 + P3P4 / 4
    P = T1 + (3/4) * T1T2

    return P, A, B