#### Archived

This topic is now archived and is closed to further replies.

# Dealing with floating point error??

This topic is 6775 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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..

##### Share on other sites
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

##### Share on other sites
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??

1. 1
Rutin
46
2. 2
3. 3
4. 4
5. 5
JoeJ
19

• 11
• 14
• 9
• 10
• 12
• ### Forum Statistics

• Total Topics
633003
• Total Posts
3009831
• ### Who's Online (See full list)

There are no registered users currently online

×