Is there a faster way to make this angle comparision?

51 views Asked by At

I have two unitary vectors P and Q in Cartesian coordinates. I need a very fast way to know if the angle between then is smaller than a certain amount A. The best way I could think of is:

if(acos(dot(P, Q)) < A)
    cull();
else
    draw();

or, conversely:

if(dot(P, Q) > cos(A))
    cull();
else
    draw();

for the bigger the angle, smaller its cosine. It is for a culling algorithm. The object won't be drawn if the angle is smaller than A (out of the field of vision), so, a small amount of false negative is acceptable (I can occasionally send to GPU something out of the field of view), But false positive is not (I can't refrain from rendering something inside the field of view).

What is the fastest way to do this? Can I get any better than I am already doing?

0

There are 0 answers