Advertisement
theosib

rounding error nicer width

May 26th, 2018
209
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.54 KB | None | 0 0
  1. run:
  2. Correct entity width: 0.59375
  3.  
  4. *** First we move an entity around the way vanilla code does and see the problem...
  5.  
  6. Starting out at some place in the world:
  7.  
  8. Xmin=1.8,Xmax=2.39375,w=0.5937499999999998
  9. Xcenter=2.096875
  10.  
  11. Have the entity get shoved around for a while...
  12.  
  13. Shifting Xmin and Xmax both by:
  14. +0.01562500000000011
  15. +0.015625000000000114
  16. +0.01562500000000011
  17. +0.015625000000000114
  18. +0.01562500000000011
  19. +0.015625000000000114
  20. +0.01562500000000011
  21. +0.015625000000000114
  22. +0.01562500000000011
  23. +0.015625000000000114
  24. +0.01562500000000011
  25. +0.015625000000000114
  26. +0.015625000000000003
  27. +0.015625000000000222
  28.  
  29. Finally ended up at:
  30. Xmin=2.0187500000000034,Xmax=2.6125,w=0.5937499999999964
  31. Xcenter=2.3156250000000016
  32. new width is 0.5937499999999964, 3.552713678800501E-15 smaller than it should be
  33.  
  34. Imagine it got shoved one last time, against a wall to the west:
  35. New bounding box and computed center:
  36. Xmin=2.0,Xmax=2.5937499999999964,w=0.5937499999999964
  37. Xcenter=2.2968749999999982
  38.  
  39. Only the center is saved to disk. When reloaded, we get this:
  40. Reloaded center and computed faces:
  41. Xcenter=2.2968749999999982
  42. Xmin=1.9999999999999982,Xmax=2.5937499999999982,w=0.59375
  43. The west face now intersects the wall by -1.7763568394002505E-15
  44.  
  45. Imagine instead it got shoved one last time, against a wall to the east:
  46. New bounding box and computed center:
  47. Xmin=2.4062500000000036,Xmax=3.0,w=0.5937499999999964
  48. Xcenter=2.7031250000000018
  49.  
  50. Only the center is saved to disk. When reloaded, we get this:
  51. Reloaded center and computed faces:
  52. Xcenter=2.7031250000000018
  53. Xmin=2.4062500000000018,Xmax=3.0000000000000018,w=0.59375
  54. The east face now intersects the wall by 1.7763568394002505E-15
  55.  
  56.  
  57. *** Now try again with code that maintains consistency between bounds and center...
  58.  
  59. Starting out at some place in the world:
  60.  
  61. Xmin=1.8,Xmax=2.39375,w=0.5937499999999998
  62. Xcenter=2.096875
  63.  
  64. Have the entity get shoved around for a while...
  65.  
  66. Shifting Xmin and Xmax both by:
  67. +0.01562500000000011
  68. +0.015625000000000114
  69. +0.015625000000000114
  70. +0.015625000000000114
  71. +0.015625000000000114
  72. +0.015625000000000114
  73. +0.015625000000000114
  74. +0.015625000000000114
  75. +0.015625000000000114
  76. +0.015625000000000114
  77. +0.015625000000000114
  78. +0.015625000000000114
  79. -0.015625000000000226
  80. +0.015625000000000114
  81. -0.015625000000000222
  82. +0.015625000000000114
  83. -0.015625000000000226
  84. +0.015625000000000114
  85. -0.015625000000000222
  86. +0.015625000000000114
  87. -0.015625000000000226
  88. +0.015625000000000114
  89. -0.015625000000000222
  90. +0.015625000000000114
  91. -0.015625000000000226
  92. +0.015625000000000114
  93. -0.015625000000000222
  94. +0.015625000000000114
  95. -0.015625000000000226
  96. +0.015625000000000114
  97. -0.015625000000000222
  98. +0.015625000000000114
  99. -0.015625000000000226
  100. +0.015625000000000114
  101. -0.015625000000000222
  102. +0.015625000000000114
  103. -0.015625000000000226
  104. +0.015625000000000114
  105. -0.015625000000000222
  106. +0.015625000000000114
  107. -0.015625000000000226
  108. +0.015625000000000114
  109. -0.015625000000000222
  110. +0.015625000000000114
  111. -0.015625000000000226
  112. +0.015625000000000114
  113. -0.015625000000000222
  114. +0.015625000000000114
  115. -0.015625000000000226
  116. +0.015625000000000114
  117. -0.015625000000000222
  118. +0.015625000000000114
  119. -0.015625000000000226
  120. +0.015625000000000114
  121. -0.015625000000000222
  122. +0.015625000000000114
  123. -0.015625000000000226
  124. +0.015625000000000114
  125. -0.015625000000000222
  126. +0.015625000000000114
  127. -0.015625000000000226
  128. +0.015625000000000114
  129. -0.015625000000000222
  130. +0.015625000000000114
  131. -0.015625000000000226
  132. +0.015625000000000114
  133. -0.015625000000000222
  134. +0.015625000000000114
  135. -0.015625000000000226
  136. +0.015625000000000114
  137. -0.015625000000000222
  138. +0.015625000000000114
  139. -0.015625000000000226
  140. +0.015625000000000114
  141. -0.015625000000000222
  142. +0.015625000000000114
  143. -0.015625000000000226
  144. +0.015625000000000114
  145. -0.015625000000000222
  146. +0.015625000000000114
  147. -0.015625000000000226
  148. +0.015625000000000114
  149. -0.015625000000000222
  150. +0.015625000000000114
  151. -0.015625000000000226
  152. +0.015625000000000114
  153. -0.015625000000000222
  154. +0.015625000000000114
  155. -0.015625000000000226
  156. +0.015625000000000114
  157. -0.015625000000000222
  158. +0.015625000000000114
  159. -0.015625000000000226
  160. +0.015625000000000114
  161. -0.015625000000000222
  162. +0.015625000000000114
  163. -0.015625000000000226
  164. +0.015625000000000114
  165. -0.015625000000000222
  166. +0.015625000000000114
  167.  
  168. Finally ended up at:
  169. Xmin=1.9874999999999803,Xmax=2.5812499999999803,w=0.59375
  170. Xcenter=2.2843749999999803
  171. new width is 0.59375, 0.0 smaller than it should be
  172.  
  173. Imagine it got shoved one last time, against a wall to the west:
  174. New bounding box and computed center:
  175. Xmin=1.0,Xmax=1.59375,w=0.59375
  176. Xcenter=1.296875
  177.  
  178. Only the center is saved to disk. When reloaded, we get this:
  179. Reloaded center and computed faces:
  180. Xcenter=1.296875
  181. Xmin=1.0,Xmax=1.59375,w=0.59375
  182. The west face now intersects the wall by 0.0
  183.  
  184. Imagine instead it got shoved one last time, against a wall to the east:
  185. New bounding box and computed center:
  186. Xmin=2.40625,Xmax=3.0,w=0.59375
  187. Xcenter=2.703125
  188.  
  189. Only the center is saved to disk. When reloaded, we get this:
  190. Reloaded center and computed faces:
  191. Xcenter=2.703125
  192. Xmin=2.40625,Xmax=3.0,w=0.59375
  193. The east face now intersects the wall by 0.0
  194. BUILD SUCCESSFUL (total time: 0 seconds)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement