Advertisement

Dealing with floating point error??

Started by April 05, 2000 10:30 PM
1 comment, last by Void 24 years, 7 months ago
Take the scenario Say I got two points A and B that represents start and end points of a rod, both floating point. I calculate B as follows B = Rotation * Translation (Predefined Length) * A So the distance from point A to B should be equal to the predefined length (within tolerance say 0.0005), but after really many calculations, the floating point error willl slowly accumulate to a point that the distance will not be equal to the length. (ie the length of rod starts changing) How should I deal with this accumulative error?? Thanks..
I''ve run into this problem before, and basically found a few ways of dealing with it, none of which are perfect but all of which "more or less" work.
My first method was to always calculate everything from a "base position", this worked for me because I had an obvious reference. This keeps the serious cumulative problems from happening, but won''t work if your reference point isn''t obvious (I was working in 2D so it was a lot easier)
My second method is to not fix the other end of the rod, but rather to fix the length... so, instead of A, you would have B-length at the end of your equation. Granted this could cause a shift during rotation but it will probably be less detectable than your rod length changing suddenly and oddly.
Somewhat like the second method, another method is to determine center of rotation and make sure that the rod is still long enough in both directions... this can be slow tho.
You can extend the length methods to only have the length "verified" every so many translation/rotation steps.

HTH
-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
Advertisement
thanks..

Actually the calculation I gave above is sort of wrong..

The end of the link is the translation portion of the matrix calcuated by

Current Transformation Matrix * Rotation * Translation

The translation in the x axis is the length of the link, which does not change.

I have calculated everything from a reference point but after many calculations, the distance from the end of the rods will still exceed the length of the link (+/- tolerance)

Maybe it is just a rare occurance?? This how I calculate the points between the rods

// load identity matrix into a transformation matrix, F
// create translation matrix to base reference point, T

// create rotation matrix of rod, R
// create translation matrix from the length of rod, L

// start of rod is the base reference
// end of rod is the translation portion of matrix calculated by
// F = T * R * L

This is for 1 rod. I have similar calculations for multiple rods, forming an link chain of rods.

Am I wrong there??

Thanks for your time

This topic is closed to new replies.

Advertisement