aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2012-01-13 20:25:15 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2012-01-13 20:25:15 +0000
commit4e48405a0889f7949d0b6604f07e3c1efdac297e (patch)
tree965b24e8c1e781f966e07b60fef210e07f1781b7
parent8888e13737a6697aaf8684ae8ff85db28047f535 (diff)
fix 'overlapping/intersecting triangles' issue, patch by Christian Borss.
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=649891 We are using a speaker setup which includes, among others, a "front left", "front right", "center", "top center", and a "floor center" speaker. We observed that a sound source panned slightly right beside the "center" is almost solely played back via the "center" while a sound source panned slightly left beside the "center" is played back by the "front left", the "top center", and the "floor center" speaker. This has the effect that the auditory source- width jumps, if we move the panned sound source from right to left. The reason is as follows: for the measured azimuth/elevation angles of our speaker positions (e.g., 3 elevated center speakers at 2°, 2°, and 3° azimuth angle), define_loudspeakers() returns intersecting triangles. The attached patch solves this issue. svn path=/trunk/externals/vbap/; revision=15871
-rw-r--r--define_loudspeakers.c18
1 files changed, 10 insertions, 8 deletions
diff --git a/define_loudspeakers.c b/define_loudspeakers.c
index 7ec06f8..5c7e478 100644
--- a/define_loudspeakers.c
+++ b/define_loudspeakers.c
@@ -546,6 +546,8 @@ static int lines_intersect(int i,int j,int k,int l,t_ls lss[MAX_LS_AMOUNT])
//t_float angle;
t_float dist_ij,dist_kl,dist_iv3,dist_jv3,dist_inv3,dist_jnv3;
t_float dist_kv3,dist_lv3,dist_knv3,dist_lnv3;
+ // TODO epsilon needs to be updated for 64-bit/double precision
+ t_float epsilon = 1e-9;
ls_cross_prod(lss[i],lss[j],&v1);
ls_cross_prod(lss[k],lss[l],&v2);
@@ -567,17 +569,17 @@ static int lines_intersect(int i,int j,int k,int l,t_ls lss[MAX_LS_AMOUNT])
dist_lnv3 = (vec_angle(neg_v3,lss[l]));
/* if one of loudspeakers is close to crossing point, don't do anything*/
- if(fabsf(dist_iv3) <= 0.01 || fabsf(dist_jv3) <= 0.01 ||
- fabsf(dist_kv3) <= 0.01 || fabsf(dist_lv3) <= 0.01 ||
- fabsf(dist_inv3) <= 0.01 || fabsf(dist_jnv3) <= 0.01 ||
- fabsf(dist_knv3) <= 0.01 || fabsf(dist_lnv3) <= 0.01 )
+ if(fabsf(dist_iv3) <= epsilon || fabsf(dist_jv3) <= epsilon ||
+ fabsf(dist_kv3) <= epsilon || fabsf(dist_lv3) <= epsilon ||
+ fabsf(dist_inv3) <= epsilon || fabsf(dist_jnv3) <= epsilon ||
+ fabsf(dist_knv3) <= epsilon || fabsf(dist_lnv3) <= epsilon )
return(0);
// if crossing point is on line between both loudspeakers return 1
- if (((fabsf(dist_ij - (dist_iv3 + dist_jv3)) <= 0.01 ) &&
- (fabsf(dist_kl - (dist_kv3 + dist_lv3)) <= 0.01)) ||
- ((fabsf(dist_ij - (dist_inv3 + dist_jnv3)) <= 0.01) &&
- (fabsf(dist_kl - (dist_knv3 + dist_lnv3)) <= 0.01 ))) {
+ if (((fabsf(dist_ij - (dist_iv3 + dist_jv3)) <= epsilon) &&
+ (fabsf(dist_kl - (dist_kv3 + dist_lv3)) <= epsilon)) ||
+ ((fabsf(dist_ij - (dist_inv3 + dist_jnv3)) <= epsilon) &&
+ (fabsf(dist_kl - (dist_knv3 + dist_lnv3)) <= epsilon))) {
return (1);
} else {
return (0);