dsound: Correctly calculate angle between vectors with equal and opposite directions.

Signed-off-by: Andrew Eikum <aeikum@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Andrew Eikum 2018-07-24 11:05:06 -05:00 committed by Alexandre Julliard
parent e32fe9ba81
commit 469c497849

View file

@ -111,7 +111,13 @@ static inline D3DVALUE AngleBetweenVectorsRad (const D3DVECTOR *a, const D3DVECT
return 0;
cos = product/(la*lb);
angle = acos(cos);
if(cos > 1.f){
angle = 0;
}else if(cos < -1.f){
angle = M_PI;
}else{
angle = acos(cos);
}
TRACE("angle between (%f,%f,%f) and (%f,%f,%f) = %f radians (%f degrees)\n", a->x, a->y, a->z, b->x,
b->y, b->z, angle, RadToDeg(angle));
return angle;