diff options
author | XANTRONIX Development | 2022-02-22 12:34:28 -0500 |
---|---|---|
committer | XANTRONIX Development | 2022-02-22 12:34:28 -0500 |
commit | 08664e8d3f22e7d2885bef930f696e33c88827d6 (patch) | |
tree | 1e6119a46e62076bd46dd2d2563a49427727ad28 /src | |
parent | 8a3be441021b006c5e913141daf9c20b8ade9450 (diff) | |
download | xas-08664e8d3f22e7d2885bef930f696e33c88827d6.tar.gz xas-08664e8d3f22e7d2885bef930f696e33c88827d6.tar.bz2 xas-08664e8d3f22e7d2885bef930f696e33c88827d6.zip |
Holy shit we're in business
Diffstat (limited to 'src')
-rw-r--r-- | src/spatial.c | 37 |
1 files changed, 18 insertions, 19 deletions
diff --git a/src/spatial.c b/src/spatial.c index 791c6f9..4a93fdd 100644 --- a/src/spatial.c +++ b/src/spatial.c @@ -78,14 +78,23 @@ static void rotate(xas_spatial_coord rotation, static int within_cone(xas_spatial_coord coord, xas_spatial_cone cone) { - xas_spatial_coord apex_to_x; + xas_spatial_coord apex_to_x_vect, + axis_vect; - float cosf_angle = cosf(cone.angle / 2.0f); + int is_infinite; - diff(&apex_to_x, cone.coord, coord); + diff(&apex_to_x_vect, cone.apex, coord); + diff(&axis_vect, cone.apex, cone.base); - return dotf(apex_to_x, cone.rotation) / magnf(apex_to_x) / magnf(cone.rotation) - > cosf_angle; + is_infinite = dotf(apex_to_x_vect, axis_vect) + / magnf(apex_to_x_vect) + / magnf(axis_vect) > cosf(cone.angle / 2.0f); + + if (!is_infinite) { + return 0; + } + + return dotf(apex_to_x_vect, axis_vect) / magnf(axis_vect) < magnf(axis_vect); } static int buffer_realloc(xas_spatial_scene *scene, @@ -177,22 +186,12 @@ ssize_t scene_fill(xas_spatial_scene *scene, int16_t *dest = (int16_t *)(scene->buffer + 1); xas_spatial_cone cone_l = { - .coord = scene->speaker_l, - .rotation = { - .x = 0.0f, - .y = 0.5f * M_PI, - .z = 0.0f - }, - + .apex = scene->speaker_l, + .base = { scene->speaker_l.x - 20.0f, scene->speaker_l.y, scene->speaker_l.z }, .angle = M_PI / 4.0f }, cone_r = { - .coord = scene->speaker_r, - .rotation = { - .x = 0.0f, - .y = 1.5f * M_PI, - .z = 0.0f - }, - + .apex = scene->speaker_r, + .base = { scene->speaker_r.x + 20.0f, scene->speaker_r.y, scene->speaker_r.z }, .angle = M_PI / 4.0f }; |