so3.scm 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087
  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. ;;; review aspects of SO3
  21. ;;; Euler-angles coordinate system is also defined in manifold.scm
  22. (define Euler-angles
  23. (coordinate-system-at 'Euler 'Euler-patch SO3))
  24. (define Euler-angles-chi (Euler-angles '->coords))
  25. (define Euler-angles-chi-inverse (Euler-angles '->point))
  26. (define-coordinates (up theta phi psi) Euler-angles)
  27. (define Euler-angles-basis (coordinate-system->basis Euler-angles))
  28. ;;; for the moment define
  29. ;;; alternate-angles coordinate system is also defined in manifold.scm
  30. (define alternate-angles
  31. (coordinate-system-at 'alternate 'alternate-patch SO3))
  32. (define alternate-angles-chi (alternate-angles '->coords))
  33. (define alternate-angles-chi-inverse (alternate-angles '->point))
  34. (define-coordinates (up vartheta varphi varpsi) alternate-angles)
  35. (define alternate-angles-basis (coordinate-system->basis alternate-angles))
  36. (define time-line the-real-line)
  37. (define time-chi (time-line '->coords))
  38. (define time-chi-inverse (time-line '->point))
  39. (define-coordinates t time-line)
  40. #|
  41. ;;;----------------------------------------------------------------
  42. ;;; Derive basis for rotations about rectangular coordinate axes.
  43. ;;; Of course, these have the generators.
  44. (pe ((D (lambda (xyz)
  45. (((D rotate-x) 'theta)
  46. ((rotate-x (- 'theta)) xyz))))
  47. (up 'x 'y 'z)))
  48. (down (up 0 0 0)
  49. (up 0 0 1)
  50. (up 0 -1 0))
  51. (pe ((D (lambda (xyz)
  52. (((D rotate-y) 'theta)
  53. ((rotate-y (- 'theta)) xyz))))
  54. (up 'x 'y 'z)))
  55. (down (up 0 0 -1)
  56. (up 0 0 0)
  57. (up 1 0 0))
  58. (pe ((D (lambda (xyz)
  59. (((D rotate-z) 'theta)
  60. ((rotate-z (- 'theta)) xyz))))
  61. (up 'x 'y 'z)))
  62. (down (up 0 1 0)
  63. (up -1 0 0)
  64. (up 0 0 0))
  65. |#
  66. ;;; tuple multipliers for rotation are obtained with the procedures
  67. ;;; rotate-x-tuple, rotate-y-tuple, rotate-z-tuple
  68. #|
  69. want to define vector fields in the group parameter manifold
  70. that correspond to particular spatial rotations
  71. (define (equation-x p q)
  72. (let ((theta (ref q 0))
  73. (phi (ref q 1))
  74. (psi (ref q 2))
  75. (a (ref p 0))
  76. (b (ref p 1))
  77. (c (ref p 2)))
  78. ((D (lambda (eps)
  79. (- (* (rotate-z-tuple (+ phi (* a eps)))
  80. (rotate-x-tuple (+ theta (* b eps)))
  81. (rotate-z-tuple (+ psi (* c eps))))
  82. (* (rotate-x-tuple eps)
  83. (rotate-z-tuple phi)
  84. (rotate-x-tuple theta)
  85. (rotate-z-tuple psi)))))
  86. 0)))
  87. ;;; kind of big
  88. (define (equation2-x p q)
  89. (let ((theta (ref q 0))
  90. (phi (ref q 1))
  91. (psi (ref q 2))
  92. (a (ref p 0))
  93. (b (ref p 1))
  94. (c (ref p 2)))
  95. ((D (lambda (eps)
  96. (- (* (rotate-z-tuple (+ phi (* a eps)))
  97. (rotate-x-tuple (+ theta (* b eps)))
  98. (rotate-z-tuple (+ psi (* c eps)))
  99. (rotate-z-tuple (- psi))
  100. (rotate-x-tuple (- theta))
  101. (rotate-z-tuple (- phi)))
  102. (rotate-x-tuple eps))))
  103. 0)))
  104. (pe (equation2-x (up 'a 'b 'c) (up 'theta 'phi 'psi)))
  105. (down
  106. (up 0
  107. (+ (* c (cos theta)) a)
  108. (+ (* c (cos phi) (sin theta)) (* -1 b (sin phi))))
  109. (up (+ (* -1 c (cos theta)) (* -1 a))
  110. 0
  111. (+ -1 (* c (sin phi) (sin theta)) (* b (cos phi))))
  112. (up (+ (* -1 c (cos phi) (sin theta)) (* b (sin phi)))
  113. (+ 1 (* -1 c (sin phi) (sin theta)) (* -1 b (cos phi)))
  114. 0))
  115. ;;; mechanical solution
  116. (load "/usr/local/scmutils/src/solve/linreduce")
  117. (define foo-x
  118. (solve
  119. (lambda (p)
  120. (list->vector
  121. (map simplify
  122. (ultra-flatten (equation2-x p (up 'theta 'phi 'psi))))))
  123. 3 9 list))
  124. (pe ((cadr foo-x) #()))
  125. (up (/ (* -1 (sin phi) (cos theta)) (sin theta))
  126. (cos phi)
  127. (/ (sin phi) (sin theta)))
  128. ;;; e_x is therefore
  129. ;;; therefore
  130. (define e_x
  131. (+ (* (/ (* -1 (sin phi) (cos theta)) (sin theta)) d/dphi)
  132. (* (cos phi) d/dtheta)
  133. (* (/ (sin phi) (sin theta)) d/dpsi)))
  134. ;;; checks with MTW p.243 (watch notation: phi<->psi )
  135. ;;;----------------------------------------------------------------
  136. ;;; now for the other two
  137. (define (equation2-z p q)
  138. (let ((theta (ref q 0))
  139. (phi (ref q 1))
  140. (psi (ref q 2))
  141. (a (ref p 0))
  142. (b (ref p 1))
  143. (c (ref p 2)))
  144. ((D (lambda (eps)
  145. (- (* (rotate-z-tuple (+ phi (* a eps)))
  146. (rotate-x-tuple (+ theta (* b eps)))
  147. (rotate-z-tuple (+ psi (* c eps)))
  148. (rotate-z-tuple (- psi))
  149. (rotate-x-tuple (- theta))
  150. (rotate-z-tuple (- phi)))
  151. (rotate-z-tuple eps))))
  152. 0)))
  153. (pe (equation2-z (up 'a 'b 'c) (up 'theta 'phi 'psi)))
  154. (down
  155. (up 0
  156. (+ -1 (* c (cos theta)) a)
  157. (+ (* c (cos phi) (sin theta)) (* -1 b (sin phi))))
  158. (up (+ 1 (* -1 c (cos theta)) (* -1 a))
  159. 0
  160. (+ (* c (sin phi) (sin theta)) (* b (cos phi))))
  161. (up (+ (* -1 c (cos phi) (sin theta)) (* b (sin phi)))
  162. (+ (* -1 c (sin phi) (sin theta)) (* -1 b (cos phi)))
  163. 0))
  164. (define foo-z
  165. (solve
  166. (lambda (p)
  167. (list->vector
  168. (map simplify
  169. (ultra-flatten (equation2-z p (up 'theta 'phi 'psi))))))
  170. 3 9 list))
  171. (pe ((cadr foo-z) #()))
  172. (up 1 0 0)
  173. so
  174. (define e_z d/dphi)
  175. ;;;----------------------------------------------------------------
  176. (define (equation2-y p q)
  177. (let ((theta (ref q 0))
  178. (phi (ref q 1))
  179. (psi (ref q 2))
  180. (a (ref p 0))
  181. (b (ref p 1))
  182. (c (ref p 2)))
  183. ((D (lambda (eps)
  184. (- (* (rotate-z-tuple (+ phi (* a eps)))
  185. (rotate-x-tuple (+ theta (* b eps)))
  186. (rotate-z-tuple (+ psi (* c eps)))
  187. (rotate-z-tuple (- psi))
  188. (rotate-x-tuple (- theta))
  189. (rotate-z-tuple (- phi)))
  190. (rotate-y-tuple eps))))
  191. 0)))
  192. (pe (equation2-y (up 'a 'b 'c) (up 'theta 'phi 'psi)))
  193. (down
  194. (up 0
  195. (+ (* c (cos theta)) a)
  196. (+ 1 (* c (cos phi) (sin theta)) (* -1 b (sin phi))))
  197. (up (+ (* -1 c (cos theta)) (* -1 a))
  198. 0
  199. (+ (* c (sin phi) (sin theta)) (* b (cos phi))))
  200. (up (+ -1 (* -1 c (cos phi) (sin theta)) (* b (sin phi)))
  201. (+ (* -1 c (sin phi) (sin theta)) (* -1 b (cos phi)))
  202. 0))
  203. (define foo-y
  204. (solve
  205. (lambda (p)
  206. (list->vector
  207. (map simplify
  208. (ultra-flatten (equation2-y p (up 'theta 'phi 'psi))))))
  209. 3 9 list))
  210. (pe ((cadr foo-y) #()))
  211. (up (/ (* (cos theta) (cos phi)) (sin theta))
  212. (sin phi)
  213. (/ (* -1 (cos phi)) (sin theta)))
  214. (define e_y
  215. (+ (* (/ (* (cos phi) (cos theta)) (sin theta)) d/dphi)
  216. (* (sin phi) d/dtheta)
  217. (* (/ (* -1 (cos phi)) (sin theta)) d/dpsi)))
  218. ;;; interchanging psi phi to compare to mtw, checks
  219. ;;; summary
  220. |#
  221. (define e_x
  222. (+ (* (/ (* -1 (sin phi) (cos theta)) (sin theta)) d/dphi)
  223. (* (cos phi) d/dtheta)
  224. (* (/ (sin phi) (sin theta)) d/dpsi)))
  225. (define e_y
  226. (+ (* (/ (* (cos phi) (cos theta)) (sin theta)) d/dphi)
  227. (* (sin phi) d/dtheta)
  228. (* (/ (* -1 (cos phi)) (sin theta)) d/dpsi)))
  229. (define e_z d/dphi)
  230. #|
  231. ;;;----------------------------------------------------------------
  232. ;;; [e_x , e_y] + e_z = 0
  233. (pe (((+ (commutator e_x e_y) e_z)
  234. (literal-manifold-function 'f Euler-angles))
  235. (Euler-angles-chi-inverse (up 'theta 'phi 'psi))))
  236. 0
  237. ;;; [e_y , e_z] + e_x = 0
  238. (pe (((+ (commutator e_y e_z) e_x)
  239. (literal-manifold-function 'f Euler-angles))
  240. (Euler-angles-chi-inverse (up 'theta 'phi 'psi))))
  241. 0
  242. (pe (((+ (commutator e_z e_x) e_y)
  243. (literal-manifold-function 'f Euler-angles))
  244. (Euler-angles-chi-inverse (up 'theta 'phi 'psi))))
  245. 0
  246. |#
  247. (define so3-vector-basis
  248. (down e_x e_y e_z))
  249. (define so3-dual-basis
  250. (vector-basis->dual so3-vector-basis Euler-angles))
  251. (define so3-basis
  252. (make-basis so3-vector-basis so3-dual-basis))
  253. #|
  254. (pe ((so3-dual-basis so3-vector-basis)
  255. (Euler-angles-chi-inverse (up 'theta 'phi 'psi))))
  256. (up (down 1 0 0) (down 0 1 0) (down 0 0 1))
  257. ;;; the structure constants
  258. (pe (s:map
  259. (lambda (e~k)
  260. (s:map
  261. (lambda (e_i)
  262. (s:map
  263. (lambda (e_j)
  264. ((e~k (commutator e_i e_j))
  265. (Euler-angles-chi-inverse (up 'theta 'phi 'psi))))
  266. so3-vector-basis))
  267. so3-vector-basis))
  268. so3-dual-basis))
  269. (up (down (down 0 0 0) (down 0 0 -1) (down 0 1 0))
  270. (down (down 0 0 1) (down 0 0 0) (down -1 0 0))
  271. (down (down 0 -1 0) (down 1 0 0) (down 0 0 0)))
  272. |#
  273. (define so3-structure-constants
  274. (up (down (down 0 0 0) (down 0 0 -1) (down 0 1 0))
  275. (down (down 0 0 1) (down 0 0 0) (down -1 0 0))
  276. (down (down 0 -1 0) (down 1 0 0) (down 0 0 0))))
  277. ;;;----------------------------------------------------------------
  278. ;;; Euler velocities as components of differential...
  279. ;;; differential of d/dt takes derivatives of functions on rotations
  280. ;;; along paths in rotations
  281. #|
  282. (pe
  283. (let* ((gamma (compose
  284. Euler-angles-chi-inverse
  285. (up (literal-function 'f^theta)
  286. (literal-function 'f^phi)
  287. (literal-function 'f^psi))
  288. time-chi)))
  289. ((((differential gamma) d/dt)
  290. (literal-manifold-function 'f Euler-angles))
  291. (time-chi-inverse 't))))
  292. (+ (* ((D f^phi) t)
  293. (((partial 1) f) (up (f^theta t) (f^phi t) (f^psi t))))
  294. (* ((D f^theta) t)
  295. (((partial 0) f) (up (f^theta t) (f^phi t) (f^psi t))))
  296. (* ((D f^psi) t)
  297. (((partial 2) f) (up (f^theta t) (f^phi t) (f^psi t)))))
  298. ;;; components of the differential of d/dt on the Euler basis
  299. (pe (let* ((gamma (compose
  300. Euler-angles-chi-inverse
  301. (up (literal-function 'f^theta)
  302. (literal-function 'f^phi)
  303. (literal-function 'f^psi))
  304. time-chi))
  305. (Euler-basis-over-gamma
  306. (basis->basis-over-map gamma Euler-angles-basis))
  307. (1form-basis-over-gamma
  308. (basis->1form-basis Euler-basis-over-gamma)))
  309. (s:map (lambda (w) ((w ((differential gamma) d/dt))
  310. (time-chi-inverse 't)))
  311. 1form-basis-over-gamma)))
  312. (up ((D f^theta) t) ((D f^phi) t) ((D f^psi) t))
  313. |#
  314. #|
  315. computing components of quasi-velocity on so3-basis
  316. (pe
  317. (let* ((gamma (compose
  318. Euler-angles-chi-inverse
  319. (up (literal-function 'f^theta)
  320. (literal-function 'f^phi)
  321. (literal-function 'f^psi))
  322. time-chi))
  323. (basis-over-gamma (basis->basis-over-map gamma so3-basis))
  324. (1form-basis (basis->1form-basis basis-over-gamma))
  325. (vector-basis (basis->vector-basis basis-over-gamma)))
  326. (s:map (lambda (w)
  327. ((w ((differential gamma) d/dt))
  328. (time-chi-inverse 't)))
  329. 1form-basis)))
  330. (up
  331. (+ (* (sin (f^phi t)) (sin (f^theta t)) ((D f^psi) t))
  332. (* (cos (f^phi t)) ((D f^theta) t)))
  333. (+ (* -1 (cos (f^phi t)) (sin (f^theta t)) ((D f^psi) t))
  334. (* (sin (f^phi t)) ((D f^theta) t)))
  335. (+ (* (cos (f^theta t)) ((D f^psi) t)) ((D f^phi) t)))
  336. compare to angular velocity components
  337. (pe ((Euler->omega (up (literal-function 'f^theta)
  338. (literal-function 'f^phi)
  339. (literal-function 'f^psi)))
  340. 't))
  341. (matrix-by-rows
  342. (list
  343. (+ (* (sin (f^phi t)) (sin (f^theta t)) ((D f^psi) t))
  344. (* (cos (f^phi t)) ((D f^theta) t))))
  345. (list
  346. (+ (* -1 (cos (f^phi t)) (sin (f^theta t)) ((D f^psi) t))
  347. (* (sin (f^phi t)) ((D f^theta) t))))
  348. (list (+ (* (cos (f^theta t)) ((D f^psi) t)) ((D f^phi) t))))
  349. it checks.
  350. |#
  351. #|
  352. what are the vector fields for which the quasivelocities are the
  353. body components of the angular velocities?
  354. omega_body = M^T omega = M^-1 omega
  355. M = Rz(phi) Rx(theta) Rz(psi)
  356. M^T = M^-1 = Rz(-psi) Rx(-theta) Rz(-phi)
  357. spatial components of vectors rotate by M^-1 to get body components
  358. e_x, e_y, e_z are the basis vector fields that correspond
  359. to rotation about the x, y, z axes
  360. they are vector fields on the space of euler angles
  361. e_xp, e_yp, e_zp are basis vectors that correspond to rotation
  362. about body xp, yp, zp axes
  363. ep(f) = e(f) M
  364. (pe (* (rotate-z-tuple 'phi)
  365. (* (rotate-x-tuple 'theta)
  366. (rotate-z-tuple 'psi))))
  367. (down
  368. (up (+ (* -1 (sin psi) (cos theta) (sin phi)) (* (cos psi) (cos phi)))
  369. (+ (* (sin psi) (cos theta) (cos phi)) (* (sin phi) (cos psi)))
  370. (* (sin theta) (sin psi)))
  371. (up (+ (* -1 (cos theta) (sin phi) (cos psi)) (* -1 (sin psi) (cos phi)))
  372. (+ (* (cos theta) (cos psi) (cos phi)) (* -1 (sin psi) (sin phi)))
  373. (* (sin theta) (cos psi)))
  374. (up (* (sin theta) (sin phi)) (* -1 (sin theta) (cos phi)) (cos theta)))
  375. (pe (* (down 'e_x 'e_y 'e_z)
  376. (* (rotate-z-tuple 'phi)
  377. (* (rotate-x-tuple 'theta)
  378. (rotate-z-tuple 'psi)))))
  379. (down
  380. (+ (* -1 (sin psi) (cos theta) (sin phi) e_x)
  381. (* (sin psi) (cos theta) (cos phi) e_y)
  382. (* (cos psi) (cos phi) e_x)
  383. (* (sin phi) (cos psi) e_y)
  384. (* (sin theta) (sin psi) e_z))
  385. (+ (* -1 (cos theta) (sin phi) (cos psi) e_x)
  386. (* (cos theta) (cos psi) (cos phi) e_y)
  387. (* -1 (sin psi) (cos phi) e_x)
  388. (* -1 (sin psi) (sin phi) e_y)
  389. (* (sin theta) (cos psi) e_z))
  390. (+ (* (sin theta) (sin phi) e_x)
  391. (* -1 (sin theta) (cos phi) e_y)
  392. (* (cos theta) e_z)))
  393. (pe ((dtheta
  394. (down
  395. (+ (* -1 (sin psi) (cos theta) (sin phi) e_x)
  396. (* (sin psi) (cos theta) (cos phi) e_y)
  397. (* (cos psi) (cos phi) e_x)
  398. (* (sin phi) (cos psi) e_y)
  399. (* (sin theta) (sin psi) e_z))
  400. (+ (* -1 (cos theta) (sin phi) (cos psi) e_x)
  401. (* (cos theta) (cos psi) (cos phi) e_y)
  402. (* -1 (sin psi) (cos phi) e_x)
  403. (* -1 (sin psi) (sin phi) e_y)
  404. (* (sin theta) (cos psi) e_z))
  405. (+ (* (sin theta) (sin phi) e_x)
  406. (* -1 (sin theta) (cos phi) e_y)
  407. (* (cos theta) e_z))))
  408. (Euler-angles-chi-inverse
  409. (up 'theta 'phi 'psi))))
  410. (down (cos psi) (* -1 (sin psi)) 0)
  411. (pe ((dphi
  412. (down
  413. (+ (* -1 (sin psi) (cos theta) (sin phi) e_x)
  414. (* (sin psi) (cos theta) (cos phi) e_y)
  415. (* (cos psi) (cos phi) e_x)
  416. (* (sin phi) (cos psi) e_y)
  417. (* (sin theta) (sin psi) e_z))
  418. (+ (* -1 (cos theta) (sin phi) (cos psi) e_x)
  419. (* (cos theta) (cos psi) (cos phi) e_y)
  420. (* -1 (sin psi) (cos phi) e_x)
  421. (* -1 (sin psi) (sin phi) e_y)
  422. (* (sin theta) (cos psi) e_z))
  423. (+ (* (sin theta) (sin phi) e_x)
  424. (* -1 (sin theta) (cos phi) e_y)
  425. (* (cos theta) e_z))))
  426. (Euler-angles-chi-inverse
  427. (up 'theta 'phi 'psi))))
  428. (down (/ (sin psi) (sin theta)) (/ (cos psi) (sin theta)) 0)
  429. (pe ((dpsi
  430. (down
  431. (+ (* -1 (sin psi) (cos theta) (sin phi) e_x)
  432. (* (sin psi) (cos theta) (cos phi) e_y)
  433. (* (cos psi) (cos phi) e_x)
  434. (* (sin phi) (cos psi) e_y)
  435. (* (sin theta) (sin psi) e_z))
  436. (+ (* -1 (cos theta) (sin phi) (cos psi) e_x)
  437. (* (cos theta) (cos psi) (cos phi) e_y)
  438. (* -1 (sin psi) (cos phi) e_x)
  439. (* -1 (sin psi) (sin phi) e_y)
  440. (* (sin theta) (cos psi) e_z))
  441. (+ (* (sin theta) (sin phi) e_x)
  442. (* -1 (sin theta) (cos phi) e_y)
  443. (* (cos theta) e_z))))
  444. (Euler-angles-chi-inverse
  445. (up 'theta 'phi 'psi))))
  446. (down (/ (* -1 (cos theta) (sin psi)) (sin theta))
  447. (/ (* -1 (cos psi) (cos theta)) (sin theta))
  448. 1)
  449. #|
  450. d/dtheta (down (cos psi)
  451. (* -1 (sin psi))
  452. 0)
  453. d/dphi (down (/ (sin psi) (sin theta))
  454. (/ (cos psi) (sin theta))
  455. 0)
  456. d/dpsi (down (/ (* -1 (sin psi) (cos theta)) (sin theta))
  457. (/ (* -1 (cos psi) (cos theta)) (sin theta))
  458. 1)
  459. deduce that
  460. |#
  461. |#
  462. (define ep_x
  463. (+ (* (cos psi) d/dtheta)
  464. (* (/ (sin psi) (sin theta)) d/dphi)
  465. (* (/ (* -1 (sin psi) (cos theta)) (sin theta)) d/dpsi)))
  466. (define ep_y
  467. (+ (* (* -1 (sin psi)) d/dtheta)
  468. (* (/ (cos psi) (sin theta)) d/dphi)
  469. (* (/ (* -1 (cos psi) (cos theta)) (sin theta)) d/dpsi)))
  470. (define ep_z d/dpsi)
  471. #|
  472. what are the commutators?
  473. ;;; [ep_x , ep_y] - ep_z = 0
  474. (pe (((- (commutator ep_x ep_y) ep_z)
  475. (literal-manifold-function 'f Euler-angles))
  476. (Euler-angles-chi-inverse
  477. (up 'theta 'phi 'psi))))
  478. 0
  479. ;;; [ep_y , ep_z] - ep_x = 0
  480. (pe (((- (commutator ep_y ep_z) ep_x)
  481. (literal-manifold-function 'f Euler-angles))
  482. (Euler-angles-chi-inverse
  483. (up 'theta 'phi 'psi))))
  484. 0
  485. ;;; [ep_z , ep_x] - ep_y = 0
  486. (pe (((- (commutator ep_z ep_x) ep_y)
  487. (literal-manifold-function 'f Euler-angles))
  488. (Euler-angles-chi-inverse
  489. (up 'theta 'phi 'psi))))
  490. 0
  491. the signs of the structure constants are opposite
  492. looks promising.
  493. |#
  494. (define so3p-vector-basis
  495. (down ep_x ep_y ep_z))
  496. (define so3p-dual-basis
  497. (vector-basis->dual so3p-vector-basis Euler-angles))
  498. (define so3p-basis
  499. (make-basis so3p-vector-basis so3p-dual-basis))
  500. #|
  501. ;;; the structure constants
  502. (pe (s:map
  503. (lambda (e~k)
  504. (s:map
  505. (lambda (e_i)
  506. (s:map
  507. (lambda (e_j)
  508. ((e~k (commutator e_i e_j))
  509. (Euler-angles-chi-inverse
  510. (up 'theta 'phi 'psi))))
  511. so3p-vector-basis))
  512. so3p-vector-basis))
  513. so3p-dual-basis))
  514. (up (down (down 0 0 0) (down 0 0 1) (down 0 -1 0))
  515. (down (down 0 0 -1) (down 0 0 0) (down 1 0 0))
  516. (down (down 0 1 0) (down -1 0 0) (down 0 0 0)))
  517. |#
  518. (define so3p-structure-constants
  519. (up (down (down 0 0 0) (down 0 0 1) (down 0 -1 0))
  520. (down (down 0 0 -1) (down 0 0 0) (down 1 0 0))
  521. (down (down 0 1 0) (down -1 0 0) (down 0 0 0))))
  522. #|
  523. ;;quasivelocities on the so3p basis
  524. (pe
  525. (let* ((gamma (compose
  526. Euler-angles-chi-inverse
  527. (up (literal-function 'f^theta)
  528. (literal-function 'f^phi)
  529. (literal-function 'f^psi))
  530. time-chi))
  531. (basis-over-gamma (basis->basis-over-map gamma so3p-basis))
  532. (1form-basis (basis->1form-basis basis-over-gamma))
  533. (vector-basis (basis->vector-basis basis-over-gamma)))
  534. (s:map (lambda (w)
  535. ((w ((differential gamma) d/dt))
  536. (time-chi-inverse 't)))
  537. 1form-basis)))
  538. (up
  539. (+ (* ((D f^phi) t) (sin (f^theta t)) (sin (f^psi t)))
  540. (* (cos (f^psi t)) ((D f^theta) t)))
  541. (+ (* ((D f^phi) t) (sin (f^theta t)) (cos (f^psi t)))
  542. (* -1 (sin (f^psi t)) ((D f^theta) t)))
  543. (+ (* ((D f^phi) t) (cos (f^theta t))) ((D f^psi) t)))
  544. ;;compare to omega body
  545. (pe ((Euler->omega-body
  546. (up (literal-function 'theta)
  547. (literal-function 'phi)
  548. (literal-function 'psi))) 't))
  549. (matrix-by-rows
  550. (list
  551. (+ (* (sin (theta t)) (sin (psi t)) ((D phi) t))
  552. (* ((D theta) t) (cos (psi t)))))
  553. (list
  554. (+ (* (sin (theta t)) (cos (psi t)) ((D phi) t))
  555. (* -1 ((D theta) t) (sin (psi t)))))
  556. (list (+ (* (cos (theta t)) ((D phi) t)) ((D psi) t))))
  557. worked.
  558. check the determining equation
  559. (pe (-
  560. (*
  561. ((so3-vector-basis
  562. (literal-manifold-function 'f Euler-angles))
  563. (Euler-angles-chi-inverse
  564. (up 'theta 'phi 'psi)))
  565. (* (rotate-z-tuple 'phi)
  566. (* (rotate-x-tuple 'theta)
  567. (rotate-z-tuple 'psi))))
  568. ((so3p-vector-basis
  569. (literal-manifold-function 'f Euler-angles))
  570. (Euler-angles-chi-inverse
  571. (up 'theta 'phi 'psi)))))
  572. (down 0 0 0)
  573. |#
  574. #|
  575. ;;;****************************************************************
  576. ;;; Instead of Euler use an alternate set of angles ...
  577. ;;;****************************************************************
  578. |#
  579. (define (Angles->M q)
  580. (let ((vartheta (ref q 0))
  581. (varphi (ref q 1))
  582. (varpsi (ref q 2)))
  583. (* (rotate-z-tuple varphi)
  584. (rotate-x-tuple vartheta)
  585. (rotate-y-tuple varpsi))))
  586. (define (Angles->M^-1 q)
  587. (let ((vartheta (ref q 0))
  588. (varphi (ref q 1))
  589. (varpsi (ref q 2)))
  590. (* (rotate-y-tuple (- varpsi))
  591. (rotate-x-tuple (- vartheta))
  592. (rotate-z-tuple (- varphi)))))
  593. #|
  594. ;;; (load "tracetranspose")
  595. (define ((equation0 vartheta varphi varpsi) p)
  596. (let ((a (ref p 0)) (b (ref p 1)) (c (ref p 2)))
  597. (let ((M ((D (lambda (t) (- (* (Angles->M (up (+ vartheta (* a t))
  598. (+ varphi (* b t))
  599. (+ varpsi (* c t))))
  600. (Angles->M^-1 (up vartheta varphi varpsi)))
  601. (rotate-x-tuple t))))
  602. 0)))
  603. (up (ref M 0 1)
  604. (ref M 0 2)
  605. (ref M 1 2)))))
  606. (pe ((equation0 'vartheta 'varphi 'varpsi) (up 'a 'b 'c)))
  607. (up (+ (* c (sin vartheta)) b)
  608. (+ (* -1 c (cos varphi) (cos vartheta)) (* -1 a (sin varphi)))
  609. (+ -1 (* -1 c (cos vartheta) (sin varphi)) (* a (cos varphi))))
  610. (pe ((cadr (solve (equation0 'vartheta 'varphi 'varpsi) 3 3 list)) #()))
  611. (up (cos varphi) (* (tan vartheta) (sin varphi)) (/ (* -1 (sin varphi)) (cos vartheta)))
  612. (define ((equation1 vartheta varphi varpsi) p)
  613. (let ((a (ref p 0)) (b (ref p 1)) (c (ref p 2)))
  614. (let ((M ((D (lambda (t) (- (* (Angles->M (up (+ vartheta (* a t))
  615. (+ varphi (* b t))
  616. (+ varpsi (* c t))))
  617. (Angles->M^-1 (up vartheta varphi varpsi)))
  618. (rotate-y-tuple t))))
  619. 0)))
  620. (up (ref M 0 1)
  621. (ref M 0 2)
  622. (ref M 1 2)))))
  623. (pe ((cadr (solve (equation1 'vartheta 'varphi 'varpsi) 3 3 list)) #()))
  624. (up (sin varphi) (* -1 (tan vartheta) (cos varphi)) (/ (cos varphi) (cos vartheta)))
  625. (define ((equation2 vartheta varphi varpsi) p)
  626. (let ((a (ref p 0)) (b (ref p 1)) (c (ref p 2)))
  627. (let ((M ((D (lambda (t) (- (* (Angles->M (up (+ vartheta (* a t))
  628. (+ varphi (* b t))
  629. (+ varpsi (* c t))))
  630. (Angles->M^-1 (up vartheta varphi varpsi)))
  631. (rotate-z-tuple t))))
  632. 0)))
  633. (up (ref M 0 1)
  634. (ref M 0 2)
  635. (ref M 1 2)))))
  636. (pe ((cadr (solve (equation2 'vartheta 'varphi 'varpsi) 3 3 list)) #()))
  637. (up 0 1 0)
  638. |#
  639. (define ea_x
  640. (+ (* (cos varphi) d/dvartheta)
  641. (* (* (sin varphi) (tan vartheta)) d/dvarphi)
  642. (* (/ (* -1 (sin varphi)) (cos vartheta)) d/dvarpsi)))
  643. (define ea_y
  644. (+ (* (sin varphi) d/dvartheta)
  645. (* (* -1 (cos varphi) (tan vartheta)) d/dvarphi)
  646. (* (/ (cos varphi) (cos vartheta)) d/dvarpsi)))
  647. (define ea_z d/dvarphi)
  648. (define so3a-vector-basis
  649. (down ea_x ea_y ea_z))
  650. (define so3a-dual-basis
  651. (vector-basis->dual so3a-vector-basis alternate-angles))
  652. (define so3a-basis
  653. (make-basis so3a-vector-basis so3a-dual-basis))
  654. #|
  655. (pe (((+ (commutator ea_x ea_y) ea_z)
  656. (literal-manifold-function 'f alternate-angles))
  657. (alternate-angles-chi-inverse
  658. (up 'vartheta 'varphi 'varpsi))))
  659. 0
  660. (pe (((+ (commutator ea_y ea_z) ea_x)
  661. (literal-manifold-function 'f alternate-angles))
  662. (alternate-angles-chi-inverse
  663. (up 'vartheta 'varphi 'varpsi))))
  664. 0
  665. (pe (((+ (commutator ea_z ea_x) ea_y)
  666. (literal-manifold-function 'f alternate-angles))
  667. (alternate-angles-chi-inverse
  668. (up 'vartheta 'varphi 'varpsi))))
  669. 0
  670. (pe ((so3a-dual-basis so3a-vector-basis)
  671. (alternate-angles-chi-inverse
  672. (up 'vartheta 'varphi 'varpsi))))
  673. (up (down 1 0 0) (down 0 1 0) (down 0 0 1))
  674. ;;; the structure constants
  675. (pe (s:map
  676. (lambda (e~k)
  677. (s:map
  678. (lambda (e_i)
  679. (s:map
  680. (lambda (e_j)
  681. ((e~k (commutator e_i e_j))
  682. (alternate-angles-chi-inverse
  683. (up 'vartheta 'varphi 'varpsi))))
  684. so3a-vector-basis))
  685. so3a-vector-basis))
  686. so3a-dual-basis))
  687. (up (down (down 0 0 0) (down 0 0 -1) (down 0 1 0))
  688. (down (down 0 0 1) (down 0 0 0) (down -1 0 0))
  689. (down (down 0 -1 0) (down 1 0 0) (down 0 0 0)))
  690. |#
  691. (define so3a-structure-constants
  692. (up (down (down 0 0 0) (down 0 0 -1) (down 0 1 0))
  693. (down (down 0 0 1) (down 0 0 0) (down -1 0 0))
  694. (down (down 0 -1 0) (down 1 0 0) (down 0 0 0))))
  695. #|
  696. (pe (* (down 'ea_x 'ea_y 'ea_z)
  697. (Angles->M (up 'vartheta 'varphi 'varpsi))))
  698. (down
  699. (+ (* -1 ea_x (sin varpsi) (sin vartheta) (sin varphi))
  700. (* ea_y (sin varpsi) (sin vartheta) (cos varphi))
  701. (* ea_x (cos varpsi) (cos varphi))
  702. (* ea_y (sin varphi) (cos varpsi))
  703. (* -1 ea_z (cos vartheta) (sin varpsi)))
  704. (+ (* -1 ea_x (cos vartheta) (sin varphi))
  705. (* ea_y (cos vartheta) (cos varphi))
  706. (* ea_z (sin vartheta)))
  707. (+ (* ea_x (sin vartheta) (sin varphi) (cos varpsi))
  708. (* -1 ea_y (sin vartheta) (cos varpsi) (cos varphi))
  709. (* ea_x (sin varpsi) (cos varphi))
  710. (* ea_y (sin varpsi) (sin varphi))
  711. (* ea_z (cos vartheta) (cos varpsi))))
  712. (pe ((dvartheta (down
  713. (+ (* -1 ea_x (sin varpsi) (sin vartheta) (sin varphi))
  714. (* ea_y (sin varpsi) (sin vartheta) (cos varphi))
  715. (* ea_x (cos varpsi) (cos varphi))
  716. (* ea_y (sin varphi) (cos varpsi))
  717. (* -1 ea_z (cos vartheta) (sin varpsi)))
  718. (+ (* -1 ea_x (cos vartheta) (sin varphi))
  719. (* ea_y (cos vartheta) (cos varphi))
  720. (* ea_z (sin vartheta)))
  721. (+ (* ea_x (sin vartheta) (sin varphi) (cos varpsi))
  722. (* -1 ea_y (sin vartheta) (cos varpsi) (cos varphi))
  723. (* ea_x (sin varpsi) (cos varphi))
  724. (* ea_y (sin varpsi) (sin varphi))
  725. (* ea_z (cos vartheta) (cos varpsi)))))
  726. (alternate-angles-chi-inverse
  727. (up 'vartheta 'varphi 'varpsi))))
  728. (down (cos varpsi) 0 (sin varpsi))
  729. (pe ((dvarphi (down
  730. (+ (* -1 ea_x (sin varpsi) (sin vartheta) (sin varphi))
  731. (* ea_y (sin varpsi) (sin vartheta) (cos varphi))
  732. (* ea_x (cos varpsi) (cos varphi))
  733. (* ea_y (sin varphi) (cos varpsi))
  734. (* -1 ea_z (cos vartheta) (sin varpsi)))
  735. (+ (* -1 ea_x (cos vartheta) (sin varphi))
  736. (* ea_y (cos vartheta) (cos varphi))
  737. (* ea_z (sin vartheta)))
  738. (+ (* ea_x (sin vartheta) (sin varphi) (cos varpsi))
  739. (* -1 ea_y (sin vartheta) (cos varpsi) (cos varphi))
  740. (* ea_x (sin varpsi) (cos varphi))
  741. (* ea_y (sin varpsi) (sin varphi))
  742. (* ea_z (cos vartheta) (cos varpsi)))))
  743. (alternate-angles-chi-inverse
  744. (up 'vartheta 'varphi 'varpsi))))
  745. (down (/ (* -1 (sin varpsi)) (cos vartheta)) 0 (/ (cos varpsi) (cos vartheta)))
  746. (pe ((dvarpsi (down
  747. (+ (* -1 ea_x (sin varpsi) (sin vartheta) (sin varphi))
  748. (* ea_y (sin varpsi) (sin vartheta) (cos varphi))
  749. (* ea_x (cos varpsi) (cos varphi))
  750. (* ea_y (sin varphi) (cos varpsi))
  751. (* -1 ea_z (cos vartheta) (sin varpsi)))
  752. (+ (* -1 ea_x (cos vartheta) (sin varphi))
  753. (* ea_y (cos vartheta) (cos varphi))
  754. (* ea_z (sin vartheta)))
  755. (+ (* ea_x (sin vartheta) (sin varphi) (cos varpsi))
  756. (* -1 ea_y (sin vartheta) (cos varpsi) (cos varphi))
  757. (* ea_x (sin varpsi) (cos varphi))
  758. (* ea_y (sin varpsi) (sin varphi))
  759. (* ea_z (cos vartheta) (cos varpsi)))))
  760. (alternate-angles-chi-inverse
  761. (up 'vartheta 'varphi 'varpsi))))
  762. (down (* (sin varpsi) (tan vartheta)) 1 (* -1 (cos varpsi) (tan vartheta)))
  763. d/dvartheta
  764. (down (cos varpsi) 0 (sin varpsi))
  765. d/dvarphi
  766. (down (/ (* -1 (sin varpsi)) (cos vartheta)) 0 (/ (cos varpsi) (cos vartheta)))
  767. d/dvarpsi
  768. (down (* (sin varpsi) (tan vartheta)) 1 (* -1 (cos varpsi) (tan vartheta)))
  769. |#
  770. (define eap_x
  771. (+ (* (cos varpsi) d/dvartheta)
  772. (* (/ (* -1 (sin varpsi)) (cos vartheta)) d/dvarphi)
  773. (* (* (sin varpsi) (tan vartheta)) d/dvarpsi)))
  774. (define eap_y
  775. d/dvarpsi)
  776. (define eap_z
  777. (+ (* (sin varpsi) d/dvartheta)
  778. (* (/ (cos varpsi) (cos vartheta)) d/dvarphi)
  779. (* (* -1 (cos varpsi) (tan vartheta)) d/dvarpsi)))
  780. #|
  781. (pe (((- (commutator eap_x eap_y) eap_z)
  782. (literal-manifold-function 'f alternate-angles))
  783. (alternate-angles-chi-inverse
  784. (up 'vartheta 'varphi 'varpsi))))
  785. 0
  786. (pe (((- (commutator eap_y eap_z) eap_x)
  787. (literal-manifold-function 'f alternate-angles))
  788. (alternate-angles-chi-inverse
  789. (up 'vartheta 'varphi 'varpsi))))
  790. 0
  791. (pe (((- (commutator eap_z eap_x) eap_y)
  792. (literal-manifold-function 'f alternate-angles))
  793. (alternate-angles-chi-inverse
  794. (up 'vartheta 'varphi 'varpsi))))
  795. 0
  796. |#
  797. (define so3ap-vector-basis
  798. (down eap_x eap_y eap_z))
  799. (define so3ap-dual-basis
  800. (vector-basis->dual so3ap-vector-basis alternate-angles))
  801. (define so3ap-basis
  802. (make-basis so3ap-vector-basis so3ap-dual-basis))
  803. #|
  804. (pe ((s:map
  805. so3ap-dual-basis
  806. so3ap-vector-basis)
  807. (alternate-angles-chi-inverse
  808. (up 'vartheta 'varphi 'varpsi))))
  809. (down (up 1 0 0) (up 0 1 0) (up 0 0 1))
  810. ;;; structure-constants
  811. (pe (s:map
  812. (lambda (e~k)
  813. (s:map
  814. (lambda (e_i)
  815. (s:map
  816. (lambda (e_j)
  817. ((e~k (commutator e_i e_j))
  818. (alternate-angles-chi-inverse
  819. (up 'vartheta 'varphi 'varpsi))))
  820. so3ap-vector-basis))
  821. so3ap-vector-basis))
  822. so3ap-dual-basis))
  823. (up (down (down 0 0 0) (down 0 0 1) (down 0 -1 0))
  824. (down (down 0 0 -1) (down 0 0 0) (down 1 0 0))
  825. (down (down 0 1 0) (down -1 0 0) (down 0 0 0)))
  826. |#
  827. (define so3ap-structure-constants
  828. (up (down (down 0 0 0) (down 0 0 1) (down 0 -1 0))
  829. (down (down 0 0 -1) (down 0 0 0) (down 1 0 0))
  830. (down (down 0 1 0) (down -1 0 0) (down 0 0 0))))
  831. #|
  832. ;;;&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
  833. check angular velocities in alternate angles
  834. (pe (let ((q (up (literal-function 'vartheta)
  835. (literal-function 'varphi)
  836. (literal-function 'varpsi))))
  837. (wcross->w (* (Angles->M^-1 (q 't))
  838. ((D (lambda (t) (Angles->M (q t)))) 't)))))
  839. (up
  840. (+ (* -1 (cos (vartheta t)) (sin (varpsi t)) ((D varphi) t))
  841. (* ((D vartheta) t) (cos (varpsi t))))
  842. (+ (* (sin (vartheta t)) ((D varphi) t)) ((D varpsi) t))
  843. (+ (* (cos (vartheta t)) (cos (varpsi t)) ((D varphi) t))
  844. (* ((D vartheta) t) (sin (varpsi t)))))
  845. (pe
  846. (let* ((gamma (compose
  847. alternate-angles-chi-inverse
  848. (up (literal-function 'vartheta)
  849. (literal-function 'varphi)
  850. (literal-function 'varpsi))
  851. time-chi))
  852. (basis-over-gamma (basis->basis-over-map gamma so3ap-basis))
  853. (1form-basis (basis->1form-basis basis-over-gamma))
  854. (vector-basis (basis->vector-basis basis-over-gamma)))
  855. (s:map (lambda (w)
  856. ((w ((differential gamma) d/dt))
  857. (time-chi-inverse 't)))
  858. 1form-basis)))
  859. (up
  860. (+ (* -1 (cos (vartheta t)) (sin (varpsi t)) ((D varphi) t))
  861. (* ((D vartheta) t) (cos (varpsi t))))
  862. (+ (* (sin (vartheta t)) ((D varphi) t)) ((D varpsi) t))
  863. (+ (* (cos (vartheta t)) (cos (varpsi t)) ((D varphi) t))
  864. (* ((D vartheta) t) (sin (varpsi t)))))
  865. |#
  866. ;;; A theorem of SO3
  867. #|
  868. (define-coordinates (up x y z) R3-rect)
  869. (define Jz (- (* x d/dy) (* y d/dx)))
  870. (define Jx (- (* y d/dz) (* z d/dy)))
  871. (define Jy (- (* z d/dx) (* x d/dz)))
  872. (pe (- (series:sum
  873. (((exp (* 'alpha D))
  874. (lambda (alpha)
  875. (* (Euler->M
  876. (series:sum
  877. (((exp (* alpha e_z)) Euler-angles-chi)
  878. ((point Euler-angles) (up 'theta 'phi 'psi)))
  879. 1))
  880. (up 'x 'y 'z))))
  881. 0)
  882. 5)
  883. (series:sum
  884. (((exp (* 'alpha Jz)) (chart R3-rect))
  885. ((point R3-rect)
  886. (* (Euler->M (up 'theta 'phi 'psi))
  887. (up 'x 'y 'z))))
  888. 5)))
  889. (up 0 0 0)
  890. (pe (- (series:sum
  891. (((exp (* 'alpha D))
  892. (lambda (alpha)
  893. (* (Euler->M
  894. (series:sum
  895. (((exp (* alpha e_x)) Euler-angles-chi)
  896. ((point Euler-angles) (up 'theta 'phi 'psi)))
  897. 4))
  898. (up 'x 'y 'z))))
  899. 0)
  900. 3)
  901. (series:sum
  902. (((exp (* 'alpha Jx)) (chart R3-rect))
  903. ((point R3-rect)
  904. (* (Euler->M (up 'theta 'phi 'psi))
  905. (up 'x 'y 'z))))
  906. 3)))
  907. (up 0 0 0)
  908. (M((exp(a*e_x)chi_SO3) m_SO3))*xyz_R3
  909. = ((exp(a*J_x)chi_R3)
  910. (M (chi_SO3 m_SO3))*xyz_R3)
  911. |#