using fixed-point floating point to represent position

Please don't post Bullet support questions here, use the above forums instead.
Post Reply
kkimlabs
Posts: 3
Joined: Sun Nov 13, 2011 5:23 am

using fixed-point floating point to represent position

Post by kkimlabs »

I think it makes more sense to use fixed-point to represent position. please correct me if I'm wrong.


reason: precision of floating-point depends on the location, and it is highly clustered around 0.
consequence: you can't expect position-invariant precision.
1. people should avoid positions too far from the origin.
2. precision at (0,0,1000000) depends on the axis direction

using fixed-point
pro: guarantees position-invariant precision.
con: max value is fixed, and you should use proper scale.


But I would say the fixed-point's con is not actually that bad, since too high value is discouraged even with the floating point. It only makes the bad practice explicitly impossible.

The attached imgs are

1. fixed point resolution with 7-bit integer.
2. floating point resolution with sign bit, 3-bit exponent and 3-bit mantissa
both are scaled to have the same max.
Attachments
fixed_point.png
fixed_point.png (18.12 KiB) Viewed 6631 times
floating_point.png
floating_point.png (19.51 KiB) Viewed 6631 times
raigan2
Posts: 197
Joined: Sat Aug 19, 2006 11:52 pm

Re: using fixed-point floating point to represent position

Post by raigan2 »

I've come across this idea a couple times; here's a blog post that mentions the same concept (using 32bit or 64bit ints to store position): http://home.comcast.net/~tom_forsyth/blog.wiki.html#[[A%20matter%20of%20precision]]

(sorry about the lack of proper link, the formatting of the URL seems to be breaking this forums' embedding code)

In that article, the author suggests that implementing this would be straightforward -- position is stored in fixed-point, and all calculations happen in a local space with floating-point. I suspect that it's not as simple/easy as that (or, maybe it is and I'm not understanding the idea well enough), so if you have any experience to share, I'd be interested in hearing about it.
bone
Posts: 231
Joined: Tue Feb 20, 2007 4:56 pm

Re: using fixed-point floating point to represent position

Post by bone »

... or you can basically have the best of all worlds and just use doubles.
Post Reply