# Vector3.TransformCoordinate accuracy

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

## Recommended Posts

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.

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

##### Share on other sites
so what is the reason that made microsoft developers make this function not accurate ?!?!?!?

Execution speed?

##### Share on other sites
Quote:
 Original post by radiationzso 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.

• ### What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

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

• Total Topics
634094
• Total Posts
3015500
×