[docs] plane3d<T>::isFrontFacing(

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
morris
Posts: 36
Joined: Tue Jul 10, 2007 10:10 am

[docs] plane3d<T>::isFrontFacing(

Post by morris »

this is is just a small documentation issue.

the docs say that plane3d<T>::isFrontFacing(const vector3d< T > & lookDirection) does only work with a normalized vector. this is not true:

the idea is to check if the angle between the normal of the plane and the look direction is bigger or equal to 90°. the in those cases, the dot product of the two vectors is less or equal to 0. this is especially independent of the lengths of the two vectors if you consider the following equations:

vector a, b;
a.dot(b) = |a| * |b| * cos alpha [definition of dot product]

now alpha should be >= 90° which is pi/2:

acos(a.dot(b) / (|a| * |b|)) >= pi/2

now, if you look at the acos function (google), values bigger or equal to pi/2 are ONLY returned for arguments x with x <= 0:

a.dot(b) / (|a| * |b|) <= 0 | divide with (|a| * |b|)
a.dot(b) <= 0

therefore, a mere dot product without normalization is sufficient for isFrontFacing().
Post Reply