--[[-- Compares `current_tev` with `initial_tev`. The first boolean argument `simple` results in only four directions if true. @return (direction, distance) pan direction and distance --]] function Contact:getPath(simple, diagonal, initial_tev) initial_tev = initial_tev or self.initial_tev local x_diff = self.current_tev.x - initial_tev.x local y_diff = self.current_tev.y - initial_tev.y local direction = nil local distance = math.sqrt(x_diff*x_diff + y_diff*y_diff) if x_diff ~= 0 or y_diff ~= 0 then local v_direction = y_diff < 0 and "north" or "south" local h_direction = x_diff < 0 and "west" or "east" if (not simple and math.abs(y_diff) > 1.732*math.abs(x_diff) and math.abs(y_diff) < 3.732*math.abs(x_diff)) or (simple and diagonal) then direction = v_direction .. h_direction elseif (math.abs(x_diff) > 0.577*math.abs(y_diff)) then direction = h_direction else direction = v_direction end end return direction, distance end