SR-frames.scm 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. #| -*-Scheme-*-
  2. Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
  3. 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
  4. 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013 Massachusetts
  5. Institute of Technology
  6. This file is part of MIT/GNU Scheme.
  7. MIT/GNU Scheme is free software; you can redistribute it and/or modify
  8. it under the terms of the GNU General Public License as published by
  9. the Free Software Foundation; either version 2 of the License, or (at
  10. your option) any later version.
  11. MIT/GNU Scheme is distributed in the hope that it will be useful, but
  12. WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with MIT/GNU Scheme; if not, write to the Free Software
  17. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301,
  18. USA.
  19. |#
  20. ;;;; Special-relativity frames.
  21. ;;; A frame is defined by a Poincare transformation from a given
  22. ;;; background 4-space frame (the "ancestor-frame"). The
  23. ;;; transformation is specified by a boost magnitude and a unit-vector
  24. ;;; boost direction, relative to the ancestor frame, and the position
  25. ;;; of the origin of the frame being defined in the ancestor frame.
  26. ;;; The events are absolute, in that it is always possible to compare
  27. ;;; them to determine if two are the same. They will be represented
  28. ;;; with coordinates relative to some arbitrary absolute frame,
  29. ;;; "the-ether".
  30. ;;; To keep us from going nuts, an SR frame has a name, which it uses
  31. ;;; to label coordinates in its frame.
  32. ;;; ...
  33. ;;; Implementation of the coordinates uses a put/get table.
  34. (define (make-SR-coordinates frame 4tuple)
  35. (assert (vector? 4tuple))
  36. (assert (fix:= (vector-length 4tuple) 4))
  37. (eq-put! 4tuple 'SR-coordinates #t)
  38. (claim! 4tuple frame)
  39. 4tuple)
  40. (define (SR-coordinates? coords)
  41. (eq-get coords 'SR-coordinates))
  42. (define (SR-name coords)
  43. ((frame-owner coords) 'name))
  44. ;;; SR frames
  45. (define (coordinates->event ancestor-frame this-frame
  46. boost-direction v/c origin)
  47. ;;; FBE move after define
  48. ;;(assert (eq? (frame-owner origin) ancestor-frame))
  49. (define (c->e coords)
  50. (assert (SR-coordinates? coords))
  51. ((point ancestor-frame)
  52. (make-SR-coordinates ancestor-frame
  53. (+ ((general-boost2 boost-direction v/c)
  54. coords)
  55. origin))))
  56. (assert (eq? (frame-owner origin) ancestor-frame))
  57. c->e)
  58. (define (event->coordinates ancestor-frame this-frame
  59. boost-direction v/c origin)
  60. ;;; FBE move after define
  61. ;;(assert (eq? (frame-owner origin) ancestor-frame))
  62. (define (e->c event)
  63. (assert (event? event))
  64. (make-SR-coordinates this-frame
  65. ((general-boost2 (- boost-direction) v/c)
  66. (- ((chart ancestor-frame) event)
  67. origin))))
  68. (assert (eq? (frame-owner origin) ancestor-frame))
  69. e->c)
  70. #|
  71. ;;; Galilean test
  72. (define (this->ancestor x) x)
  73. (define (ancestor->this x) x)
  74. (define (coordinates->event ancestor-frame this-frame
  75. boost-direction v/c origin)
  76. (assert (eq? (frame-owner origin) ancestor-frame))
  77. (define (c->e coords)
  78. (assert (SR-coordinates? coords))
  79. ((point ancestor-frame)
  80. (make-SR-coordinates ancestor-frame
  81. (+ (this->ancestor coords)
  82. origin))))
  83. c->e)
  84. (define (event->coordinates ancestor-frame this-frame
  85. boost-direction v/c origin)
  86. (assert (eq? (frame-owner origin) ancestor-frame))
  87. (define (e->c event)
  88. (assert (event? event))
  89. (make-SR-coordinates this-frame
  90. (ancestor->this
  91. (- ((chart ancestor-frame) event)
  92. origin))))
  93. e->c)
  94. |#
  95. (define (boost-direction frame)
  96. (list-ref (frame-params frame) 0))
  97. (define (v/c frame)
  98. (list-ref (frame-params frame) 1))
  99. (define (coordinate-origin frame)
  100. (list-ref (frame-params frame) 2))
  101. (define make-SR-frame
  102. (frame-maker coordinates->event event->coordinates))
  103. ;;; The background frame
  104. (define* ((base-frame-point ancestor-frame this-frame) coords)
  105. (assert (SR-coordinates? coords))
  106. (assert (eq? this-frame (frame-owner coords)))
  107. (make-event coords)
  108. coords)
  109. (define* ((base-frame-chart ancestor-frame this-frame) event)
  110. (assert (event? event))
  111. (make-SR-coordinates this-frame event))
  112. (define the-ether
  113. ((frame-maker base-frame-point base-frame-chart)
  114. 'the-ether 'the-ether))
  115. #|
  116. (symbolic-constants #f)
  117. (set! *divide-out-terms* #f)
  118. ;;; Velocity addition formula
  119. (define A
  120. (make-SR-frame 'A the-ether
  121. (up 1 0 0)
  122. (/ 'va :c)
  123. (make-SR-coordinates the-ether
  124. #(0 0 0 0))))
  125. (define B
  126. (make-SR-frame 'B A
  127. (up 1 0 0)
  128. (/ 'vb :c)
  129. (make-SR-coordinates A
  130. #(0 0 0 0))))
  131. (let ((foo ((chart the-ether)
  132. ((point B)
  133. (make-SR-coordinates B
  134. (up (* :c 'tau) 0 0 0))))))
  135. (/ (ref foo 1) (/ (ref foo 0) :c)))
  136. #|
  137. (/ (+ (* (expt :c 2) va)
  138. (* (expt :c 2) vb))
  139. (+ (expt :c 2) (* va vb)))
  140. ;;; Hand simplified to:
  141. (/ (+ va vb)
  142. (+ 1 (* (/ va :c) (/ vb :c))))
  143. |#
  144. |#
  145. (define (add-v/cs v1/c v2/c)
  146. (/ (+ v1/c v2/c)
  147. (+ 1 (* v1/c v2/c))))
  148. (define (add-velocities v1 v2)
  149. (/ (+ v1 v2)
  150. (+ 1 (* (/ v1 :c) (/ v2 :c)))))
  151. #|
  152. ;;; Simple test of reversibility
  153. (define A
  154. (make-SR-frame 'A the-ether (up 1 0 0) 'va/c
  155. (make-SR-coordinates the-ether #(cta xa ya za))))
  156. ((chart A)
  157. ((point A)
  158. (make-SR-coordinates A #(ct x y z))))
  159. #|
  160. (up ct x y z)
  161. |#
  162. ;;; The ether coordinates of the origin of A relative to "the ether"
  163. ;;; is
  164. (define origin-A
  165. (coordinate-origin A))
  166. (frame-name (frame-owner origin-A))
  167. #| the-ether |#
  168. (define B
  169. (make-SR-frame 'B A (up 1 0 0) 'vba/c
  170. (make-SR-coordinates A #(ctba xba yba zba))))
  171. ((chart B)
  172. ((point B)
  173. (make-SR-coordinates B
  174. #(ct x y z))))
  175. #|
  176. (up ct x y z)
  177. |#
  178. |#
  179. #|
  180. ;;; Poincare formula
  181. (define A
  182. (make-SR-frame 'A the-ether (up 1 0 0) 'va/c
  183. (make-SR-coordinates the-ether #(cta xa ya za))))
  184. (define B
  185. (make-SR-frame 'B A (up 1 0 0) 'vba/c
  186. (make-SR-coordinates A #(ctba xba yba zba))))
  187. ;;; The ether coordinates of the origin of B relative to "the ether"
  188. ;;; is
  189. (define origin-B
  190. ((chart the-ether)
  191. ((point A)
  192. (coordinate-origin B))))
  193. origin-B
  194. #|
  195. (up
  196. (/ (+ (* cta (sqrt (+ 1 (* -1 (expt va/c 2))))) (* va/c xba) ctba)
  197. (sqrt (+ 1 (* -1 (expt va/c 2)))))
  198. (/ (+ (* ctba va/c) (* xa (sqrt (+ 1 (* -1 (expt va/c 2))))) xba)
  199. (sqrt (+ 1 (* -1 (expt va/c 2)))))
  200. (+ ya yba)
  201. (+ za zba))
  202. |#
  203. (define C
  204. (make-SR-frame 'C the-ether
  205. (up 1 0 0)
  206. (add-v/cs 'va/c 'vba/c)
  207. origin-B))
  208. ;;; A typical event.
  209. (define foo
  210. ((point the-ether)
  211. (make-SR-coordinates the-ether
  212. (up 'ct 'x 'y 'z))))
  213. |#