import math
import random


def Move(Location, xT):
    """
    This function will return the new location (as a tuple) of a particle after it has
    isotropically scattered

    Location: Location of particle before scattering
    xT: Total cross section of medium
    """
    # Sample distance to collision
    Distance = (1/xT)*math.log(random.random())

    # Sample new direction
    phi = 2*math.pi*random.random()
    u = 2*random.random() - 1
    v = math.sqrt(1-u*u)*math.cos(phi)
    w = math.sqrt(1-u*u)*math.sin(phi)

    # Move particle
    x = Location[0] + Distance*u
    y = Location[1] + Distance*v
    z = Location[2] + Distance*w

    return (x, y, z)