From 769f1c6c4087d53a2b400511baac77b510f16798 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sat, 5 Mar 2022 20:32:19 -0500 Subject: Implement move() in src/spatial.c Implement move() in src/spatial.c to translate a point in 3D space along a heading --- src/spatial.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/spatial.c b/src/spatial.c index 06c9a22..4d52738 100644 --- a/src/spatial.c +++ b/src/spatial.c @@ -68,6 +68,21 @@ static void rotate(xas_spatial_coord rotation, point->z = Yz; } +static void move(xas_spatial_coord *point, + xas_spatial_coord heading, + float speed, + float interval) { + float distance = speed * interval; + + xas_spatial_coord normal = { 0.0f, 0.0f, distance }; + + rotate(heading, &normal); + + point->x += normal.x; + point->y += normal.y; + point->z += normal.z; +} + static int within_cone(xas_spatial_coord point, xas_spatial_cone cone) { xas_spatial_coord apex_to_point_vect, -- cgit v1.2.3