Calculating angle and direction between two vectors



Normally, if we were to find the angle between two vectors, say up-vector and dir-vector, what we would do is to do a dot product between them. Since

a \cdot b = |a||b| \cos{\theta} and

\cos{\theta} = \frac{a \cdot b}{|a||b|}

dot_product_01However, since the calculated angle is the smallest / nearest angle between the two vectors, we can’t derive the (rotational) direction of one vector from the other. Thus in the following figure, it’s hard to figure out whether the direction vector is on the left or right of the up vector. The angle between two vectors calculated using dot product is always between 0° to 180°, thus we are not able to derive the direction from it. Continue reading

Simple head tracking


This is a very simple head-tracking using OpenCV and only Viola Jones’ face detection framework.

Basically the idea is to use face / head tracking to create an immersive 3D experience. This, is of course is still a very early prototype.

I whipped this up in less than an hour, so it’s very dirty and lack of any optimization. You can make the whole thing faster using CamShift algorithm, and some cleanup on the OpenGL codes.

Have fun ! Continue reading