- Home /
How do i use double precision vector3? Is this possible?
Hi,everyone. I have a very huge scene,and the transform.position overflow the vector3's float precision(7 valid number). Why there isn't double precision vector3? Anyone can solve this problem? thanks
Scale down the scene - IEEE floating-point values have greater precision as you approach zero (half the possible values are "denormalized", i.e., in between -1 and 1).
Answer by _Petroz · Nov 25, 2010 at 12:07 AM
Unless I'm missing something, I don't think floating point accuracy is related to scale, they have 7.22 digits of accuracy regardless of where you put the decimal point. http://en.wikipedia.org/wiki/IEEE_754-2008
If you are experiencing 'Spatial Jitter' due to floating point inaccuracy, here is a paper explaining the problem and possible solutions:
http://www.floatingorigin.com/pubs/thorneC-FloatingOrigin.pdf
I wrote this implementation: http://wiki.unity3d.com/index.php/Floating_Origin
If you try it out, please let me of any improvements that could be made.
While it's not "related to scale", it does prevent you having small and large scale objects at the same time. When the questioner says that his scene is "huge", we can assume it also contains small things. It is this difference in scales that cases floats to fail.
Hi, I know this is an old question but I could really use some help on this. The unifycommunity.com website has unfortunately shut down and I can't see your solution. I'm making a semi-deter$$anonymous$$istic multiplayer RTS game and I could really use some help with the imprecision of floats.
Answer by Eric5h5 · Nov 01, 2010 at 03:20 PM
There's no way to use double precision floats for Vector3. Either scale things down, or use some technique where you have "local" and "world" coordinates in order to represent large areas.
Answer by Waz · Oct 29, 2011 at 02:02 AM
To have a very large game area (eg. Solar System) with small objects (eg. a space ship, warp drive button), you will have to divide the space into areas and only logically have them distant from each other.
Answer by jcarrion · Nov 19, 2014 at 02:21 PM
There is indeed a double precision physics library around for Unity. We use it for our project www.space-simulator.com . All position , velocities , angles, transforms, etc etc.. are templated so we can choose Vector3s , DVector3 , etc.. .as required.
$$anonymous$$e too I'd really like to get that library. I'd pay a good price for it. Can't find it in Unity asset store, what is it called ? Thanks
Answer by IJM · Nov 01, 2010 at 01:49 PM
Oo how did you do that? There is really no need to do something like that. I recommend you to scale your meshes down. This will help you: (Look for "Scale factor")
thanks IJ$$anonymous$$,but my scene camera's transform position data uses another application through a UDP dll,and sometimes the position data may greater than (200000.000,0,200000.000),so I think use this "Scale factor" will lose the precesion. So,Is there another solution ?
Your answer
Follow this Question
Related Questions
Infinite space, precision problems, and multiplayer 0 Answers
Problem with animation precision 0 Answers
How to set compute shader float precision to half explicitly in Unity 2022 and Direct3D12? 1 Answer
Scene scale and float precision 1 Answer
Phyics.Raycast alternatively returns True/False with static input 2 Answers