[Verse-dev] Bug in enough library
Jiří Hnídek
jiri.hnidek at vslib.cz
Mon Jul 25 11:49:24 CEST 2005
Hi,
I found bug in enough library e_storage_object.c (physics stuff):
you use this equation:
x(t) = x(0) + speed*t + acceleration*t*t + drag
it is of course wrong. Correct equation seems so:
x(t) = x(0) + speed*t + 0.5*acceleration*t*t + drag
You can find patch in attachment.
btw: it is interesting that drag isn't supported in enough. What is
definition of drag in this case? ... I guess, that no physicist would
add drag to this equation ;-), because this equation is about kinematics
not dynamics :-).
Best regards,
Jiri
-------------- next part --------------
Index: e_storage_object.c
===================================================================
RCS file: /cvsroot/verse/quelsolaar/e_storage_object.c,v
retrieving revision 1.7
diff -u -p -r1.7 e_storage_object.c
--- e_storage_object.c 13 Jun 2005 11:13:48 -0000 1.7
+++ e_storage_object.c 25 Jul 2005 09:00:29 -0000
@@ -298,9 +298,9 @@ void e_nso_get_pos_time(ESObjectNode *no
t = &((ESObjectNode *)node)->trans;
dt = e_get_delta_time(time_s, time_f);
/* FIXME: These equations seem to miss a 0.5 factor in the last term. /emil */
- pos[0] = t->pos[0] + t->pos_speed[0] * dt + t->pos_accelerate[0] * dt * dt;
- pos[1] = t->pos[1] + t->pos_speed[1] * dt + t->pos_accelerate[1] * dt * dt;
- pos[2] = t->pos[2] + t->pos_speed[2] * dt + t->pos_accelerate[2] * dt * dt;
+ pos[0] = t->pos[0] + t->pos_speed[0] * dt + t->pos_accelerate[0] * dt * dt / 2;
+ pos[1] = t->pos[1] + t->pos_speed[1] * dt + t->pos_accelerate[1] * dt * dt / 2;
+ pos[2] = t->pos[2] + t->pos_speed[2] * dt + t->pos_accelerate[2] * dt * dt / 2;
}
void e_nso_get_rot_time(ESObjectNode *node, VNQuat64 *rot, uint32 time_s, uint32 time_f)
@@ -311,10 +311,10 @@ void e_nso_get_rot_time(ESObjectNode *no
/* FIXME: This code is very certainly incorrect -- you can't interpolate quaternions like this, can you? */
t = &((ESObjectNode *)node)->trans;
dt = e_get_delta_time(time_s, time_f);
- rot->x = t->rot.x + t->rot_speed.x * dt + t->rot_accelerate.x * dt * dt;
- rot->y = t->rot.y + t->rot_speed.y * dt + t->rot_accelerate.y * dt * dt;
- rot->z = t->rot.z + t->rot_speed.y * dt + t->rot_accelerate.y * dt * dt;
- rot->w = t->rot.w + t->rot_speed.w * dt + t->rot_accelerate.w * dt * dt;
+ rot->x = t->rot.x + t->rot_speed.x * dt + t->rot_accelerate.x * dt * dt / 2;
+ rot->y = t->rot.y + t->rot_speed.y * dt + t->rot_accelerate.y * dt * dt / 2;
+ rot->z = t->rot.z + t->rot_speed.y * dt + t->rot_accelerate.y * dt * dt / 2;
+ rot->w = t->rot.w + t->rot_speed.w * dt + t->rot_accelerate.w * dt * dt / 2;
}
void e_nso_get_scale(ESObjectNode *node, double *scale)
More information about the Verse-dev
mailing list