def spanning_plane(v0, v1, v2):
    """Return the normal N and offset K of the plane containing v0, v1 and v2.

    These are so that X = (x, y, z) is on the plane if and only if N . X == K"""

    Nx = (v1[1] - v0[1]) * (v2[2] - v0[2]) - (v1[2] - v0[2]) * (v2[1] - v0[1])
    Ny = (v1[2] - v0[2]) * (v2[0] - v0[0]) - (v1[0] - v0[0]) * (v2[2] - v0[2])
    Nz = (v1[0] - v0[0]) * (v2[1] - v0[1]) - (v1[1] - v0[1]) * (v2[0] - v0[0])
    K = Nx * v0[0] + Ny * v0[1] + Nz * v0[2]
    return (Nx, Ny, Nz), K