Newest version of angle error, including logical indexing to find the max velocity of times with decreasing Z-position