This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
math_library [2022/04/29 23:39] max [Float comparison] |
math_library [2022/05/01 18:38] (current) max |
||
---|---|---|---|
Line 10: | Line 10: | ||
* [[2D Vector]] | * [[2D Vector]] | ||
* [[3D Vector]] | * [[3D Vector]] | ||
- | * [[4D Vector]] | ||
===== Float comparison ===== | ===== Float comparison ===== | ||
Line 17: | Line 16: | ||
To learn which methods Impulse Physics offers to compare floating-point numbers, visit [[floating point comparison]]. | To learn which methods Impulse Physics offers to compare floating-point numbers, visit [[floating point comparison]]. | ||
- | |||
- | It also means that for example, 0.2 + 0.1 is not equal to 0.3; rather it is equal to 0.30000000000000004. | ||
- | Since computers are exact in comparison by default, you can see how you can run into issues with this. | ||
- | |||
- | |||
- | Impulse, therefore, offers two methods of float comparison by default. | ||
- | The default option is a combination of both the absolute and relative methods of epsilon comparison. ((http:// | ||
- | The second option is simply the computer' | ||
- | |||
- | ==== The absolute method ==== | ||
- | |||
- | The absolute method takes the absolute value of '' | ||
- | |||
- | The absolute method will work, but it does not work on large values. | ||
- | |||
- | ==== The relative method ==== | ||
- | |||
- | The relative method takes the result of the absolute method and multiplies the epsilon by '' | ||
- | |||
- | The drawback to this method is that it does not work on small values. | ||
- | |||
- | ==== The combined method ==== | ||
- | |||
- | Considering the strengths and drawbacks of the two methods above, you can combine the two to overcome these limitations. | ||
- | |||
- | The combined method takes the result of the absolute method and multiplies it by the largest absolute number out of a set of '' | ||
- | |||
- | This method gives us good results, but it is not without its drawbacks since it uses the same epsilon for the relative and the absolute tolerance. | ||
- | |||
- | For further reading, please check out [[http:// |