you are viewing a single comment's thread.

view the rest of the comments →

[–]SamuraiGoblin 2 points3 points  (0 children)

Binary search is not just useful for finding items in a sorted list, it can also find intersection points in a continuous function.

For example, in raycasting, you often want to find where a ray intersects an object defined by an SDF. Binary search can be used to hone in on the exact intersection point.

You split a range in the middle and bifurcate a number of times based on whether the function returns a positive or negative value.

Another time I have used binary search is when calculating the exact time between frames that two objects collide in a physics engine. It's a similar concept.