home *** CD-ROM | disk | FTP | other *** search
/ Programmer 7500 / MAX_PROGRAMMERS.iso / CLIPPER / MISC / MINITK.ZIP / LADDER.TK < prev    next >
Encoding:
Text File  |  1988-03-01  |  2.3 KB  |  210 lines

  1. TK!2
  2. =v
  3. #1
  4. :n
  5.  
  6. :s
  7. b
  8. :c
  9.      ****   LADDER   ****
  10. #2
  11. :n
  12. h
  13. :v
  14. 10
  15. :s
  16. i
  17. :c
  18. Level of the ladders' crossing point
  19. #3
  20. :n
  21. L1
  22. :v
  23. 40
  24. :s
  25. i
  26. :c
  27. Length of the 1st ladder
  28. #4
  29. :n
  30. L2
  31. :v
  32. 30
  33. :s
  34. i
  35. :c
  36. Length of the 2nd ladder
  37. #5
  38. :n
  39. ya
  40. :s
  41. b
  42. :c
  43. Level of touch point (1st ladder)
  44. #6
  45. :n
  46. yb
  47. :s
  48. b
  49. :c
  50. Level of touch point (2nd ladder)
  51. #7
  52. :n
  53. w
  54. :s
  55. b
  56. :c
  57. Width of the alley
  58. #8
  59. :n
  60. w0
  61. :s
  62. b
  63. :c
  64. Final width vs. first guess ratio
  65. :f
  66. 1
  67. #9
  68. :n
  69. hmax
  70. :s
  71. b
  72. :c
  73. Maximum feasible level h
  74. #11
  75. :n
  76.  
  77. :s
  78. b
  79. :c
  80.     _│<------ w ------->│
  81. #12
  82. :n
  83.  
  84. :s
  85. b
  86. :c
  87. ya | │\                 │
  88. #13
  89. :n
  90.  
  91. :s
  92. b
  93. :c
  94.    | │  \               │_
  95. #14
  96. :n
  97.  
  98. :s
  99. b
  100. :c
  101.    | │    \ L1         /│ | yb
  102. #15
  103. :n
  104.  
  105. :s
  106. b
  107. :c
  108.    | │      \     L2 /  │ |
  109. #16
  110. :n
  111.  
  112. :s
  113. b
  114. :c
  115.    | │        \   /     │ |
  116. #17
  117. :n
  118.  
  119. :s
  120. b
  121. :c
  122.    | │         /|\      │ |
  123. #18
  124. :n
  125.  
  126. :s
  127. b
  128. :c
  129.    | │      /   |  \    │ |
  130. #19
  131. :n
  132.  
  133. :s
  134. b
  135. :c
  136.    | │   /     h|    \  │ |
  137. #20
  138. :n
  139.  
  140. :s
  141. b
  142. :c
  143.  ══╧═╧/═════════╧══════\╧═╧══
  144. =u
  145. =r
  146. #1
  147. :r
  148. "             ******   LADDERS IN THE ALLEY   ******
  149. :s
  150. C
  151. #2
  152. :r
  153. L1^2 = w^2 + ya^2      " There is an alley bounded by two high buildings.
  154. #3
  155. :r
  156. L2^2 = w^2 + yb^2      " Two ladders, L1 and L2 long, rest in corners and
  157. #4
  158. :r
  159. 1/h = 1/ya + 1/yb      " lean against opposite buildings.  Given the height
  160. #5
  161. :r
  162.                        " h of the crossing point, what is the width w of the
  163. :s
  164. C
  165. #6
  166. :r
  167.                        " alley?
  168. :s
  169. C
  170. #8
  171. :r
  172. " The Iterative Solver has to be used.  Guessing the unknown w usually leads 
  173. :s
  174. C
  175. #9
  176. :r
  177. " to trouble because the interval of feasible guess values is too narrow. 
  178. :s
  179. C
  180. #10
  181. :r
  182. " A reasonable guess depends on the magnitude of L1,L2,h; we may write it as
  183. :s
  184. C
  185. #12
  186. :r
  187.            w/w0 = sqrt(min(L1,L2)^2 - (1/(1/h-1/max(L1,L2)))^2)
  188. #14
  189. :r
  190. " and assign w0=1 as the First guess.  Now iteration is invoked automatically
  191. :s
  192. C
  193. #15
  194. :r
  195. " and always converges to a correct solution for any feasible L1,L2,h.
  196. :s
  197. C
  198. #17
  199. :r
  200. 1/hmax = 1/L1 + 1/L2  " This protects against trying too large a value for h:
  201. #18
  202. :r
  203. h = min(h,hmax)       " error in this rule indicates contradictory data.
  204. #20
  205. :r
  206. "  Type =V to bring up the variable sheet, where there is a diagram.
  207. :s
  208. C
  209. %Tr,f,0,1,0,1,0
  210.