diff options
author | XANTRONIX Development | 2022-02-27 15:29:00 -0500 |
---|---|---|
committer | XANTRONIX Development | 2022-02-27 15:29:11 -0500 |
commit | a540a8d63aee39aaaa259d1db42e1af4e38f3d80 (patch) | |
tree | 1db2af9c6fdd745ef0522dc7020ddb18a06a5dd5 | |
parent | ff6126d37d950b233a9d275f0fdba1c0de8d2466 (diff) | |
download | xas-a540a8d63aee39aaaa259d1db42e1af4e38f3d80.tar.gz xas-a540a8d63aee39aaaa259d1db42e1af4e38f3d80.tar.bz2 xas-a540a8d63aee39aaaa259d1db42e1af4e38f3d80.zip |
Rename 'coord' to 'point' where applicable
Rename 'coord' to 'point' where applicable, to help disambiguate whether
a coordinate is indeed a point or a rotation vector
-rw-r--r-- | include/xas/spatial.h | 10 | ||||
-rw-r--r-- | src/spatial.c | 62 |
2 files changed, 36 insertions, 36 deletions
diff --git a/include/xas/spatial.h b/include/xas/spatial.h index db04ceb..df956a8 100644 --- a/include/xas/spatial.h +++ b/include/xas/spatial.h @@ -20,7 +20,7 @@ typedef struct _xas_spatial_cone { } xas_spatial_cone; typedef struct _xas_spatial_observer { - xas_spatial_coord coord, + xas_spatial_coord point, rotation; float width; @@ -38,7 +38,7 @@ struct _xas_spatial_object { ssize_t shift_l, shift_r; - xas_spatial_coord coord; + xas_spatial_coord point; xas_audio_stream *source; xas_spatial_object *next; }; @@ -72,7 +72,7 @@ xas_spatial_scene *xas_spatial_scene_new(xas_audio_format format, void xas_spatial_scene_destroy(xas_spatial_scene *scene); void xas_spatial_scene_set_observer(xas_spatial_scene *scene, - xas_spatial_coord coord, + xas_spatial_coord point, xas_spatial_coord rotation, float width); @@ -85,12 +85,12 @@ int xas_spatial_scene_set_speed(xas_spatial_scene *scene, float speed); int xas_spatial_scene_set_radius(xas_spatial_scene *scene, float radius); xas_spatial_object *xas_spatial_scene_add_object(xas_spatial_scene *scene, - xas_spatial_coord coord, + xas_spatial_coord point, xas_audio_stream *source); void xas_spatial_scene_position_object(xas_spatial_scene *scene, xas_spatial_object *object, - xas_spatial_coord coord); + xas_spatial_coord point); void xas_spatial_object_get_coord(xas_spatial_object *object, xas_spatial_coord *coord); diff --git a/src/spatial.c b/src/spatial.c index 654ef0b..2e1c066 100644 --- a/src/spatial.c +++ b/src/spatial.c @@ -26,10 +26,10 @@ static void diff(xas_spatial_coord *ret, ret->z = a.z - b.z; } -static float magnf(xas_spatial_coord coord) { - return sqrtf(coord.x * coord.x - + coord.y * coord.y - + coord.z * coord.z); +static float magnf(xas_spatial_coord point) { + return sqrtf(point.x * point.x + + point.y * point.y + + point.z * point.z); } static inline float degf(float rad) { @@ -43,7 +43,7 @@ static inline float degf(float rad) { } static void rotate(xas_spatial_coord rotation, - xas_spatial_coord *coord) { + xas_spatial_coord *point) { double cosY = cos(rotation.y), sinY = sin(rotation.y), cosZ = cos(rotation.z), @@ -56,14 +56,14 @@ static void rotate(xas_spatial_coord rotation, /* * Adjust vertex for Z axis rotation */ - Rx = coord->x * cosZ - coord->y * sinZ; - Ry = coord->y * cosZ + coord->x * sinZ; + Rx = point->x * cosZ - point->y * sinZ; + Ry = point->y * cosZ + point->x * sinZ; /* * Adjust vertex for X axis rotation */ - Py = Ry * cosX - coord->z * sinX; - Pz = coord->z * cosX - Ry * sinX; + Py = Ry * cosX - point->z * sinX; + Pz = point->z * cosX - Ry * sinX; /* * Adjust vertex for Y axis rotation @@ -71,12 +71,12 @@ static void rotate(xas_spatial_coord rotation, Yx = Rx * cosY - Pz * sinY; Yz = Pz * cosY - Rx * sinY; - coord->x = Yx; - coord->y = Py; - coord->z = Yz; + point->x = Yx; + point->y = Py; + point->z = Yz; } -static int within_cone(xas_spatial_coord coord, +static int within_cone(xas_spatial_coord point, xas_spatial_cone cone) { xas_spatial_coord apex_to_point_vect, axis_vect, @@ -89,7 +89,7 @@ static int within_cone(xas_spatial_coord coord, rotate(opposite, &rotated); - diff(&apex_to_point_vect, cone.apex, coord); + diff(&apex_to_point_vect, cone.apex, point); diff(&axis_vect, cone.apex, rotated); return dotf(apex_to_point_vect, axis_vect) @@ -220,11 +220,11 @@ ssize_t scene_fill(xas_spatial_scene *scene, size_t index_l, index_r; - if (!within_cone(obj->coord, cone_l)) { + if (!within_cone(obj->point, cone_l)) { value_l /= 3.0f; } - if (!within_cone(obj->coord, cone_r)) { + if (!within_cone(obj->point, cone_r)) { value_r /= 3.0f; } @@ -321,24 +321,24 @@ void xas_spatial_scene_destroy(xas_spatial_scene *scene) { void xas_spatial_scene_set_observer(xas_spatial_scene *scene, - xas_spatial_coord coord, + xas_spatial_coord point, xas_spatial_coord rotation, float width) { - scene->observer.coord = coord; + scene->observer.point = point; scene->observer.rotation = rotation; scene->observer.width = width; } static void object_position(xas_spatial_scene *scene, xas_spatial_object *object, - xas_spatial_coord coord) { + xas_spatial_coord point) { size_t delta_l_old = object->delta_l, delta_r_old = object->delta_r; - object->coord = coord; + object->point = point; - object->distance_l = dist(scene->speaker_l, coord); - object->distance_r = dist(scene->speaker_r, coord); + object->distance_l = dist(scene->speaker_l, point); + object->distance_r = dist(scene->speaker_r, point); object->delta_l = sample_delta(scene, object->distance_l); object->delta_r = sample_delta(scene, object->distance_r); object->shift_l = object->delta_l - delta_l_old; @@ -356,7 +356,7 @@ void xas_spatial_scene_set_speaker_coords(xas_spatial_scene *scene, while (obj) { xas_spatial_object *next = obj->next; - object_position(scene, obj, obj->coord); + object_position(scene, obj, obj->point); obj = next; } @@ -375,7 +375,7 @@ int xas_spatial_scene_set_radius(xas_spatial_scene *scene, float radius) { } xas_spatial_object *xas_spatial_scene_add_object(xas_spatial_scene *scene, - xas_spatial_coord coord, + xas_spatial_coord point, xas_audio_stream *source) { xas_spatial_object *object; @@ -389,13 +389,13 @@ xas_spatial_object *xas_spatial_scene_add_object(xas_spatial_scene *scene, goto error_malloc_object; } - object->coord = coord; + object->point = point; object->source = source; object->next = NULL; object->delta_l = 0; object->delta_r = 0; - object_position(scene, object, coord); + object_position(scene, object, point); if (scene->first == NULL) { scene->first = object; @@ -414,11 +414,11 @@ error_invalid_source: return NULL; } -void xas_spatial_object_get_coord(xas_spatial_object *object, - xas_spatial_coord *coord) { - coord->x = object->coord.x; - coord->y = object->coord.y; - coord->z = object->coord.z; +void xas_spatial_object_get_point(xas_spatial_object *object, + xas_spatial_coord *point) { + point->x = object->point.x; + point->y = object->point.y; + point->z = object->point.z; } xas_audio_stream *xas_spatial_scene_new_stream(xas_spatial_scene *scene, |