Fast Distance Comparison Algorithm

Comparing distances doesn’t have to be slow! Learn a simple yet valuable shortcut that’ll make distance checks significantly faster in most languages.

Hey, this is a quick post about quickly comparing the distance of two points (2D or 3D). In this article, I’ll be using Roblox Lua for demonstration, but this method ought to work in many different languages. The goal is to find a fast way to answer the questions:

  • Is a point within a certain distance of another point?
  • Which of these two points are closest to this point?

Continue reading “Fast Distance Comparison Algorithm”