Extracting frustum planes from modelview-projection matrix

Extracting viewing frustum planes from the modelview-projection matrix

In this post I’m going to explain how to extract the parameters of each frustum plane in the local space of the object with a certain modelview-projection matrix. Knowing the frustum planes may be useful in some cases. The first one that comes to my mind is to perform frustum culling, which I will explain soon in a separated post.

Continue reading

Logarithms to arbitrary base

The mathematics library in many languages ( e.g. C++) only provides us with natural (base e) logarithms and base 10 logarithms.

When programming, we sometimes need to perform logarithmic calculations that use an arbirary base. It is common, for instance, to need base 2 logarithms in order to work with sizes of binary trees, or base 8 logarithms for octrees.

The logarithm to an arbitrary base b, logb(x), can be computed from the logarithms of x and b with respect to an arbitrary base k using the following formula:

log_b(x)=log_k(x)/log_k(b)

where k could be ‘e’ or ’10′, which allows us to calculate logarithms to an arbitrary base using the standard maths library functions.