Hello all,
I have First derivative function implemented in C++. More details http://www.cplusplus.com/forum/general/103788/
Special Thank for Andy for helping me to implement it and thank for all of you guys for helping me in the previous link.
In programming, I'm dealing with a lot of variables.
x, y, z & x', y', z' & x'', y'', z'' These are only for one device. The problem is how can I deal with velocities and accelerations the way I did with positions? This is the code
I'm trying also to store x_Velocity in vector. Every time I deal with whether array or vector, the first two points of x position are affected because I'm calling the function for the velocity. Any suggestions?
Are you trying to use First_Derivative() to calculate the first few points? Rather than special casing them?
If you are special casing, and something still goes wrong, then please post the corresponding i/p values for the first 10 or so samples.
Andy
PS As you're working with C++, you could make the analysis code a lot simpler by using a 3D "vector" class (you could use std::vector (or std::array, if you're using C++11), but a fixed size, specialized class might be better here.)
You could easily enough implement you own. Or you could use one from a geometry library, like:
It worked but forgive me for this question. Why I should not consider the first points in my calculations since they are initialized as zero. About using vector or array, I thought at the first to use them but they confuse me because I need to use loop to retrieve the data. I'm thinking now to at least run the project then create a function that will be in charge of returning all the variables(x',y',z', x'', etc.) by only accepting stream data(x,y,z) as a parameter. I know it is not well-organized but at least I can track my code easily. Now I'm very close to run the project. Thanks again for your patience.
Why I should not consider the first points in my calculations since they are initialized as zero.
Because the zero values are no where near the real values, so feeding them into the equation that calculates the approximate derivative will generate meaningless values, as you see.
Forgive me but I'm still confused. If my data is zeros, I get zeros for the derivative but what the special with the first points since they are zeros?
Sorry for bothering you.
Thanks again