def project_onto(y, p, n):
    """

    Project a point onto a plane.

    Parameters
    ----------
    y : The point that should be project
    p : A point which lies on the plane
    n : The normal vector of the plane

    Returns
    -------

    proj_y : The projection onto the plane

    """

    is_1d = False
    if len(y.shape) == 1:
        is_1d = True
        y = np.atleast_2d(y)

    # make sure the plane vector is normalized
    n = n / np.linalg.norm(n)

    proj_y = y - n[None, :] * ((y - p) @ n)[:, None]

    if is_1d:
        proj_y = proj_y[0]

    return proj_y


    Project a point onto a plane.

    Parameters
    ----------
    y : The point that should be project
    p : A point which lies on the plane
    n : The normal vector of the plane

    Returns
    -------

    proj_y : The projection onto the plane

    
pymoo/util/ref_dirs/misc.py