local function in_fov (pos1, pos2, yaw, pitch, fov) local function yaw2vec (yaw, pitch) return {x = math.sin(-yaw) * math.cos(pitch), y = math.sin(pitch), z = math.cos(yaw) * math.cos(pitch)} end local function dotproduct (v1, v2) return ((v1.x * v2.x) + (v1.y * v2.y) + (v1.z * v2.z)) end local function angle (v1, v2) return math.deg(math.acos(dotproduct(v1, v2) / (vector.length(v1) * vector.length(v2)))) end local v = vector.subtract(pos2, pos1) -- v.y = 0 print(angle(yaw2vec(yaw, pitch), v)) end