Vector3.TransformCoordinate accuracy

Started by
3 comments, last by S1CA 17 years, 9 months ago
i am using c# with direct3d, u transform some vectors using Vector3.TransformCoordinate(...), i notice that it does not give accurate results, for example if i have: Vector3 v=new Vector3(0,-6,0); v = Vector3.TransformCoordinate(v, Matrix.RotationZ(-90f * Convert.ToSingle(Math.PI) / 180f))); the result is: v.X = -5.99999952 and it should be -6 v.Y = 0.0000002622683 and it should be 0 what should i do to increase accuracy? any help will be appreciated, thnx.
Advertisement
if your not happy with the results, and can do the math yourself why not just apply that math to your own function to take care of what it is u want it to do, i recently wrote all my own matrice functions in order to help me learn the underlying math etc
http://stowelly.co.uk/
so what is the reason that made microsoft developers make this function not accurate ?!?!?!?
Execution speed?
DanyATK
Quote:Original post by radiationz
so what is the reason that made microsoft developers make this function not accurate ?!?!?!?


1) IEE754 floating point numbers can't represent every number exactly within 32-bits of precision. The CPU/FPU in your computer uses IEEE floating point numbers.

2) For the details of why floating point numbers aren't always 'accurate', read "What every computer scientist should know about floating point": http://cch.loria.fr/documentation/IEEE754/ACM/goldberg.pdf

3) And as DanyATK, sometimes precision/accuracy is traded for speed. Direct3D uses single precision floating point values rather than double precision for example.

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

This topic is closed to new replies.

Advertisement