CODE_TOLD_FAST

DIA_TILTEX_ULTRA

May 16th, 2020
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //|/////////////////////////:DIAGRAM[SC[DIA_TILTEX_ULTRA]]///|//
  3. //|                                                          |//
  4. //|     //|/////////////////:DIAGRAM[SC[DIA_TILTEX]]:|//     |//
  5. //|     //|                                          |//     |//
  6. //|     //| Working out logic using a 4x4 tilemap:   |//     |//
  7. //|     //|                                          |//     |//
  8. //|     //| TILE[ 0 ]: ( 0 + 0.5 ) / 4 === 0.125     |//     |//
  9. //|     //| TILE[ 1 ]: ( 1 + 0.5 ) / 4 === 0.375     |//     |//
  10. //|     //| TILE[ 2 ]: ( 2 + 0.5 ) / 4 === 0.625     |//     |//
  11. //|     //| TILE[ 3 ]: ( 3 + 0.5 ) / 4 === 0.875     |//     |//
  12. //|     //|                                          |//     |//
  13. //|     //| |<----- 4 pixels / texels ----->|        |//     |//
  14. //|     //| +---+---+---+---+---+---+---+---+        |//     |//
  15. //|     //| |       |       |       |       |        |//     |//
  16. //|     //| +   0   +   1   +   2   +   3   + <<<<<  |//     |//
  17. //|     //| |       |       |       |       |    ^^  |//     |//
  18. //|     //| +---+---+---+---+---+---+---+---+    ^^  |//     |//
  19. //|     //| ^   ^  .25  ^  0.5  ^  .75  ^   ^    ^^  |//     |//
  20. //|     //| |   |       |       |       |   |    ^^  |//     |//
  21. //|     //| | 0.125   0.375   0.625   0.875 |    ^^  |//     |//
  22. //|     //| |                               |    ^^  |//     |//
  23. //|     //| 0<--WEBGL_MAPPED_RANGE_0_TO_1-->1    ^^  |//     |//
  24. //|     //|                                      ^^  |//     |//
  25. //|     //|                [ TILE_COORDINATES >>>^^] |//     |//
  26. //|     //|                (If each pixel encodes  ) |//     |//
  27. //|     //|                (a tile value on tilemap) |//     |//
  28. //|     //|                                          |//     |//
  29. //|     //|/////////////////:DIAGRAM[SC[DIA_TILTEX]]:|//     |//
  30. //|                                                          |//
  31. //|    Solving in a more detailed manner yeilds a more       |//
  32. //|    complex formula... But the results are almost         |//
  33. //|    identical. And identical enough for what I need.      |//
  34. //|                                                          |//
  35. //|    +---+---+---+---+---+---+                             |//
  36. //|    |       |       |       |                             |//
  37. //|    +   0   +   1   +   2   +                             |//
  38. //|    |       |       |       |                             |//
  39. //|    +---+---+---+---+---+---+                             |//
  40. //|    ^ ~.16~    0.5     .83  ^                             |//
  41. //|    |                       |                             |//
  42. //|    |                       |                             |//
  43. //|    |                       |                             |//
  44. //|    0<-------- 0-1 -------->1                             |//
  45. //|                                                          |//
  46. //|    1: Figure how many half segments there are:           |//
  47. //|       var num_seg = ( wid * 2 );                         |//
  48. //|                                                          |//
  49. //|    2: Get the length of a single half segment            |//
  50. //|       as portion of normalized length:                   |//
  51. //|        var nom_seg = ( 1 / num_seg );                    |//
  52. //|                                                          |//
  53. //|    3: First pixel center is one nom_seg from zero.       |//
  54. //|       Each succesive coordinate is 2 more nom_seg.       |//
  55. //|                                                          |//
  56. //|    //:til_cor: Tile Coordinate                           |//
  57. //|    //:til_tex: Tile texture/normalized position.         |//
  58. //|    til_nom = (nom_seg*1) + ( til_cor * ( nom_seg * 2 ) ) |//
  59. //|                                                          |//
  60. //|    ((1/(wid*2))*1)+(til*((1/(wid*2))*2))                 |//
  61. //|    //:::wid:::::::::til::::::wid::::::::                 |//
  62. //|                                                          |//
  63. //|                                                          |//
  64. //|    wid:3 til:0  ((1/( 3 *2))*1)+( 0 *((1/( 3 *2))*2))    |//
  65. //|    wid:3 til:1  ((1/( 3 *2))*1)+( 1 *((1/( 3 *2))*2))    |//
  66. //|    wid:3 til:2  ((1/( 3 *2))*1)+( 2 *((1/( 3 *2))*2))    |//
  67. //|                                                          |//
  68. //|    [ FORMULA:01 / fom_001 ]                              |//
  69. //|    ((1/(wid*2))*1)+(til*((1/(wid*2))*2))                 |//
  70. //|                                                          |//
  71. //|    [ FORMULA:02 / fom_002 ]                              |//
  72. //|    ( til + 0.5 ) / ( wid )                               |//
  73. //|                                                          |//
  74. //|                                                          |//
  75. //|/////////////////////////:DIAGRAM[SC[DIA_TILTEX_ULTRA]]///|//
  76.  
  77.  
  78. var pep_tim=( 0 ); //:PerfectPassTimes
  79. var pas_tim=( 0 ); //:PassTimes
  80. var fai_tim=( 0 ); //:FailTimes
  81. for( var wid = 0; wid <   1024;   wid++ ){
  82. for( var til = 0; til <= (wid-1); til++ ){
  83.  
  84.     //:Run formulas( fom ) 001 & 002:
  85.     fom_001 = ((1/(wid*2))*1)+(til*((1/(wid*2))*2));
  86.     fom_002 = ( til + 0.5 ) / ( wid )              ;
  87.  
  88.     //:formula delta:
  89.     var fom_del = Math.abs( fom_001 - fom_002 );
  90.  
  91.     //:max delta... 16 degrees of freedom in a single
  92.     //:tile when using 1024 tiles seems fine:
  93.     var max_del =( 1 / 1024 / 16 );
  94.  
  95.     if( fom_del > max_del ){
  96.         throw("[Formulas_Are_Not_The_Same]");
  97.         fai_tim++; //:fail times.
  98.     }else{
  99.  
  100.         if( 0 == fom_del ){
  101.             pep_tim++; //:PerfectPassTimes.
  102.         }else{
  103.             pas_tim++; //:pass times.
  104.         };;
  105.     };;
  106.  
  107. };;};;
  108.  
  109. console.log( "[fai_tim]:", fai_tim );
  110. console.log( "[pas_tim]:", pas_tim );
  111. console.log( "[pep_tim]:", pep_tim );
Add Comment
Please, Sign In to add comment