...

/

Postponing sqrt Computations

Postponing sqrt Computations

Learn how to optimize vector length comparisons using a proxy object.

This section will show you how to use a proxy object to postpone, or even avoid, using the computationally heavy std::sqrt() function when comparing the length of two-dimensional vectors.

A simple two-dimensional vector class

Let’s start with a simple two-dimensional vector class. It has xx and yy ...