diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/spatial.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/spatial.c b/src/spatial.c index f031ceb..98728df 100644 --- a/src/spatial.c +++ b/src/spatial.c @@ -12,6 +12,37 @@ static inline float dist(xas_spatial_coord a, xas_spatial_coord b) { + powf(b.z - a.z, 2.0f), 0.5f); } +static int point_within_cone(xas_spatial_coord coord, + xas_spatial_cone cone) { + float radius; + + /* + * XXX Perform an affine transformation of the point along with the cone, + * fixing the point of the cone at 0, 0, 0 with the open end facing to the + * right on the X axis + */ + + /* + * If the point is to the left of the cone point, then the point is not + * within the cone. + */ + if (coord.x < cone.coord.x) { + return 0; + } + + radius = tanf(cone.angle / 2.0f) * cone.coord.x; + + /* + * If the given point is outside the cone radius at its X coordinate, then + * it is outside of the cone. + */ + if (fabs(coord.y) < radius || fabs(coord.z) < radius) { + return 0; + } + + return 1; +} + static int buffer_realloc(xas_spatial_scene *scene, xas_spatial_buffer *buffer) { float seconds = scene->radius / scene->speed; |