From 02c717b5d9e6027a781c99e6973ebf8c95db860f Mon Sep 17 00:00:00 2001 From: RicardoEA <ricardo@focus.uy> Date: Wed, 2 Nov 2022 18:48:02 -0300 Subject: [PATCH] =?UTF-8?q?Corrijo=20implementaci=C3=B3n=20de=20funciones?= =?UTF-8?q?=20matem=C3=A1ticas?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../math_vector_operations.c | 22 ++++++++++++------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/Robotito/src/math_vector_operations/math_vector_operations.c b/Robotito/src/math_vector_operations/math_vector_operations.c index 96600a8..afe4d94 100644 --- a/Robotito/src/math_vector_operations/math_vector_operations.c +++ b/Robotito/src/math_vector_operations/math_vector_operations.c @@ -54,18 +54,24 @@ float dotProduct (sF3dVector_t* v, sF3dVector_t v2){ } void crossProduct (sF3dVector_t* v, sF3dVector_t v2){ - - v->x = v->y*v2.z - v->z*v2.y; - v->y = v->z*v2.x - v->x*v2.z; - v->z = v->x*v2.y - v->y*v2.x; + float vx, vy, vz; + vx = v->x; + vy = v->y; + vz = v->z; + v->x = vy*v2.z - vz*v2.y; + v->y = vz*v2.x - vx*v2.z; + v->z = vx*v2.y - vy*v2.x; } void vector_mul (sF3dMatrix_t m, sF3dVector_t* v){ - - v->x = m.x1*v->x + m.y1*v->y + m.z1*v->z; - v->y = m.x2*v->x + m.y2*v->y + m.z2*v->z; - v->z = m.x3*v->x + m.y3*v->y + m.z3*v->z; + float vx, vy, vz; + vx = v->x; + vy = v->y; + vz = v->z; + v->x = m.x1*vx + m.y1*vy + m.z1*vz; + v->y = m.x2*vx + m.y2*vy + m.z2*vz; + v->z = m.x3*vx + m.y3*vy + m.z3*vz; } -- GitLab