eph_bpn 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,633 @@
1
+ module EphBpn
2
+ module Compute
3
+ module_function
4
+
5
+ #=========================================================================
6
+ # 年月日(グレゴリオ暦)からユリウス日(JD)を計算する
7
+ #
8
+ # * フリーゲルの公式を使用する
9
+ # JD = int(365.25 * year)
10
+ # + int(year / 400)
11
+ # - int(year / 100)
12
+ # + int(30.59 (month - 2))
13
+ # + day
14
+ # + 1721088
15
+ # * 上記の int(x) は厳密には、 x を超えない最大の整数
16
+ # * 「ユリウス日」でなく「準ユリウス日」を求めるなら、
17
+ # `+ 1721088` を `- 678912` とする。
18
+ #
19
+ # @param: t (Time Object)
20
+ # @return: jd (ユリウス日)
21
+ #=========================================================================
22
+ def gc2jd(t)
23
+ year, month, day = t.year, t.month, t.day
24
+ hour, min, sec = t.hour, t.min, t.sec
25
+
26
+ begin
27
+ # 1月,2月は前年の13月,14月とする
28
+ if month < 3
29
+ year -= 1
30
+ month += 12
31
+ end
32
+ # 日付(整数)部分計算
33
+ jd = (365.25 * year).floor \
34
+ + (year / 400.0).floor \
35
+ - (year / 100.0).floor \
36
+ + (30.59 * (month - 2)).floor \
37
+ + day \
38
+ + 1721088.5
39
+ # 時間(小数)部分計算
40
+ t = (sec / 3600.0 + min / 60.0 + hour) / 24.0
41
+ return jd + t
42
+ rescue => e
43
+ raise
44
+ end
45
+ end
46
+
47
+ #=========================================================================
48
+ # JD(ユリウス日) -> JC(ユリウス世紀)
49
+ #
50
+ # * t = (JD - 2451545) / 36525.0
51
+ #
52
+ # @param: jd (ユリウス日)
53
+ # @return: jc (ユリウス世紀)
54
+ #=========================================================================
55
+ def jd2jc(jd)
56
+ return (jd - 2451545) / 36525.0
57
+ rescue => e
58
+ raise
59
+ end
60
+
61
+ #=========================================================================
62
+ # 黄道傾斜角計算
63
+ #
64
+ # * 黄道傾斜角 ε (単位: rad)を計算する。
65
+ # 以下の計算式により求める。
66
+ # ε = 84381.406 - 46.836769 * T - 0.0001831 T^2 + 0.00200340 T^3
67
+ # - 5.76 * 10^(-7) * T^4 - 4.34 * 10^(-8) * T^5
68
+ # ここで、 T は J2000.0 からの経過時間を 36525 日単位で表したユリウス
69
+ # 世紀数で、 T = (JD - 2451545) / 36525 である。
70
+ #
71
+ # @param: jc (ユリウス世紀)
72
+ # @return: eps (平均黄道傾斜角)
73
+ #=========================================================================
74
+ def compute_obliquity(jc)
75
+ return (84381.406 + \
76
+ ( -46.836769 + \
77
+ ( -0.0001831 + \
78
+ ( 0.00200340 + \
79
+ ( -5.76 * 10e-7 + \
80
+ ( -4.34 * 10e-8 ) \
81
+ * jc) * jc) * jc) * jc) * jc) * Const::AS2R
82
+ rescue => e
83
+ raise
84
+ end
85
+
86
+ #=========================================================================
87
+ # Bias 変換行列(一般的な理論)
88
+ #
89
+ # * 赤道座標(J2000.0)の極は ICRS の極に対して12時(x軸のマイナス側)の方
90
+ # 向へ 17.3±0.2 mas、18時(y軸のマイナス側)の方向へ 5.1±0.2 mas ズレ
91
+ # ているので、変換する。
92
+ # さらに、平均分点への変換はICRSでの赤経を78±10 mas、天の極を中心に回
93
+ # 転させる。
94
+ # 18時の方向の変換はx軸を-5.1mas回転
95
+ # + 1 0 0 +
96
+ # R1(θ ) = | 0 cosθ sinθ |
97
+ # + 0 -sinθ cosθ +
98
+ # 12時の方向の変換はy軸を-17.3mas回転
99
+ # + cosθ 0 -sinθ +
100
+ # R2(θ ) = | 0 1 0 |
101
+ # + sinθ 0 cosθ +
102
+ # 天の極を中心に78.0mas回転
103
+ # + cosθ sinθ 0 +
104
+ # R3(θ ) = | -sinθ cosθ 0 |
105
+ # + 0 0 1 +
106
+ #
107
+ # @param: <none>
108
+ # @return: r (回転行列)
109
+ #=========================================================================
110
+ def r_generic
111
+ r = r_x( -5.1 * Const::AS2R)
112
+ r = r_y(-17.3 * Const::AS2R, r)
113
+ r = r_z( 78.0 * Const::AS2R, r)
114
+ return r
115
+ rescue => e
116
+ raise
117
+ end
118
+
119
+ #=========================================================================
120
+ # Bias 変換行列(IAU 2006 (Fukushima-Williams 4-angle formulation) 理論)
121
+ #
122
+ # @param: <none>
123
+ # @return: r (変換行列)
124
+ #=========================================================================
125
+ def r_fw_iau_06
126
+ jc = jd2jc(2451545.0)
127
+ eps = compute_obliquity(jc)
128
+ gamma = (-0.052928 + \
129
+ (10.556378 + \
130
+ ( 0.4932044 + \
131
+ (-0.00031238 + \
132
+ (-0.000002788 + \
133
+ ( 0.0000000260) \
134
+ * jc) * jc) * jc) * jc) * jc) * Const::AS2R
135
+ phi = (84381.412819 + \
136
+ ( -46.811016 + \
137
+ ( 0.0511268 + \
138
+ ( 0.00053289 + \
139
+ ( -0.000000440 + \
140
+ ( -0.0000000176) \
141
+ * jc) * jc) * jc) * jc) * jc) * Const::AS2R
142
+ psi = ( -0.041775 + \
143
+ (5038.481484 + \
144
+ ( 1.5584175 + \
145
+ ( -0.00018522 + \
146
+ ( -0.000026452 + \
147
+ ( -0.0000000148) \
148
+ * jc) * jc) * jc) * jc) * jc) * Const::AS2R
149
+ r = r_z(gamma)
150
+ r = r_x(phi, r)
151
+ r = r_z(-psi, r)
152
+ r = r_x(-eps, r)
153
+ return r
154
+ rescue => e
155
+ raise
156
+ end
157
+
158
+ #=========================================================================
159
+ # precession(歳差)変換行列(J2000.0 用)
160
+ #
161
+ # * 歳差の変換行列
162
+ # P(ε , ψ , φ , γ ) = R1(-ε ) * R3(-ψ ) * R1(φ ) * R3(γ )
163
+ # 但し、R1, R2, R3 は x, y, z 軸の回転。
164
+ # + 1 0 0 + + cosθ sinθ 0 +
165
+ # R1(θ ) = | 0 cosθ sinθ | , R3(θ ) = | -sinθ cosθ 0 |
166
+ # + 0 -sinθ cosθ + + 0 0 1 +
167
+ # + P_11 P_12 P_13 +
168
+ # P(ε, ψ, φ, γ) = | P_21 P_22 P_23 | とすると、
169
+ # + P_31 P_32 P_33 +
170
+ # P_11 = cosψ cosγ + sinψ cosφ sinγ
171
+ # P_12 = cosψ sinγ - sinψ cosφ ̄cosγ
172
+ # P_13 = -sinψ sinφ
173
+ # P_21 = cosε sinψ cosγ - (cosε cosψ cosφ + sinε sinφ )sinγ
174
+ # P_22 = cosε sinψ cosγ + (cosε cosψ cosφ + sinε sinφ )cosγ
175
+ # P_23 = cosε cosψ sinφ - sinε cosφ
176
+ # P_31 = sinε sinψ cosγ - (sinε cosψ cosφ - cosε sinφ)sinγ
177
+ # P_32 = sinε sinψ cosγ + (sinε cosψ cosφ - cosε sinφ)cosγ
178
+ # P_33 = sinε cosψ sinφ + cosε cosφ
179
+ #
180
+ # @param: <none>
181
+ # @return: r (変換行列)
182
+ #=========================================================================
183
+ def r_prec
184
+ gamma = ((10.556403 + \
185
+ (0.4932044 + \
186
+ (-0.00031238 + \
187
+ (-0.000002788 + \
188
+ (0.0000000260) \
189
+ * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
190
+ phi = (84381.406000 + \
191
+ ( -46.811015 + \
192
+ ( 0.0511269 + \
193
+ ( 0.00053289 + \
194
+ ( -0.000000440 + \
195
+ ( -0.0000000176) \
196
+ * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
197
+ psi = (( 5038.481507 + \
198
+ ( 1.5584176 + \
199
+ ( -0.00018522 + \
200
+ ( -0.000026452 + \
201
+ ( -0.0000000148) \
202
+ * @jc) * @jc) * @jc) * @jc) * @jc) * Const::AS2R
203
+ r = r_z(gamma)
204
+ r = r_x(phi, r)
205
+ r = r_z(-psi, r)
206
+ r = r_x(-@eps, r)
207
+ return r
208
+ rescue => e
209
+ raise
210
+ end
211
+
212
+ #=========================================================================
213
+ # nutation(章動)変換行列
214
+ #
215
+ # @param: <none>
216
+ # @return: r (変換行列)
217
+ #=========================================================================
218
+ def r_nut
219
+ dpsi_ls, deps_ls = compute_lunisolar
220
+ dpsi_pl, deps_pl = compute_planetary
221
+ dpsi, deps = dpsi_ls + dpsi_pl, deps_ls + deps_pl
222
+ r = r_z(-dpsi)
223
+ r = r_x(-deps, r)
224
+ return r
225
+ rescue => e
226
+ raise
227
+ end
228
+
229
+ #=========================================================================
230
+ # 日月章動(luni-solar nutation)の計算
231
+ #
232
+ # @param: <none>
233
+ # @return: [dpsi_ls, deps_ls]
234
+ #=========================================================================
235
+ def compute_lunisolar
236
+ dp, de = 0.0, 0.0
237
+
238
+ begin
239
+ l = compute_l_iers2003(@jc)
240
+ lp = compute_lp_mhb2000(@jc)
241
+ f = compute_f_iers2003(@jc)
242
+ d = compute_d_mhb2000(@jc)
243
+ om = compute_om_iers2003(@jc)
244
+ Const::NUT_LS.reverse.each do |x|
245
+ arg = (x[0] * l + x[1] * lp + x[2] * f +
246
+ x[3] * d + x[4] * om) % Const::PI2
247
+ sarg, carg = Math.sin(arg), Math.cos(arg)
248
+ dp += (x[5] + x[6] * @jc) * sarg + x[ 7] * carg
249
+ de += (x[8] + x[9] * @jc) * carg + x[10] * sarg
250
+ end
251
+ return [dp * Const::U2R, de * Const::U2R]
252
+ rescue => e
253
+ raise
254
+ end
255
+ end
256
+
257
+ #=========================================================================
258
+ # 惑星章動(planetary nutation)
259
+ #
260
+ # @param: <none>
261
+ # @return: [dpsi_pl, deps_pl]
262
+ #=========================================================================
263
+ def compute_planetary
264
+ dp, de = 0.0, 0.0
265
+
266
+ begin
267
+ l = compute_l_mhb2000(@jc)
268
+ f = compute_f_mhb2000(@jc)
269
+ d = compute_d_mhb2000_2(@jc)
270
+ om = compute_om_mhb2000(@jc)
271
+ pa = compute_pa_iers2003(@jc)
272
+ lme = compute_lme_iers2003(@jc)
273
+ lve = compute_lve_iers2003(@jc)
274
+ lea = compute_lea_iers2003(@jc)
275
+ lma = compute_lma_iers2003(@jc)
276
+ lju = compute_lju_iers2003(@jc)
277
+ lsa = compute_lsa_iers2003(@jc)
278
+ lur = compute_lur_iers2003(@jc)
279
+ lne = compute_lne_mhb2000(@jc)
280
+ Const::NUT_PL.reverse.each do |x|
281
+ arg = (x[ 0] * l + x[ 2] * f + x[ 3] * d + x[ 4] * om +
282
+ x[ 5] * lme + x[ 6] * lve + x[ 7] * lea + x[ 8] * lma +
283
+ x[ 9] * lju + x[10] * lsa + x[11] * lur + x[12] * lne +
284
+ x[13] * pa) % Const::PI2
285
+ sarg, carg = Math.sin(arg), Math.cos(arg)
286
+ dp += x[14] * sarg + x[15] * carg
287
+ de += x[16] * sarg + x[17] * carg
288
+ end
289
+ return [dp * Const::U2R, de * Const::U2R]
290
+ rescue => e
291
+ raise
292
+ end
293
+ end
294
+
295
+ #=========================================================================
296
+ # Mean anomaly of the Moon (IERS 2003)
297
+ #
298
+ # @param: jc (ユリウス世紀)
299
+ # @return: longitude (rad)
300
+ #=========================================================================
301
+ def compute_l_iers2003(jc)
302
+ return (( 485868.249036 + \
303
+ (1717915923.2178 + \
304
+ ( 31.8792 + \
305
+ ( 0.051635 + \
306
+ ( -0.00024470) \
307
+ * jc) * jc) * jc) * jc) % Const::TURNAS) * Const::AS2R
308
+ rescue => e
309
+ raise
310
+ end
311
+
312
+ #=========================================================================
313
+ # Mean anomaly of the Sun (MHB2000)
314
+ #
315
+ # @param: jc (ユリウス世紀)
316
+ # @return: longitude (rad)
317
+ #=========================================================================
318
+ def compute_lp_mhb2000(jc)
319
+ return (( 1287104.79305 + \
320
+ (129596581.0481 + \
321
+ ( -0.5532 + \
322
+ ( 0.000136 + \
323
+ ( -0.00001149) \
324
+ * jc) * jc) * jc) * jc) % Const::TURNAS) * Const::AS2R
325
+ rescue => e
326
+ raise
327
+ end
328
+
329
+ #=========================================================================
330
+ # Mean longitude of the Moon minus that of the ascending node (IERS 2003)
331
+ #
332
+ # @param: jc (ユリウス世紀)
333
+ # @return: longitude (rad)
334
+ #=========================================================================
335
+ def compute_f_iers2003(jc)
336
+ return (( 335779.526232 + \
337
+ (1739527262.8478 + \
338
+ ( -12.7512 + \
339
+ ( -0.001037 + \
340
+ ( 0.00000417) \
341
+ * jc) * jc) * jc) * jc) % Const::TURNAS) * Const::AS2R
342
+ rescue => e
343
+ raise
344
+ end
345
+
346
+ #=========================================================================
347
+ # Mean elongation of the Moon from the Sun (MHB2000)
348
+ #
349
+ # @param: jc (ユリウス世紀)
350
+ # @return: longitude (rad)
351
+ #=========================================================================
352
+ def compute_d_mhb2000(jc)
353
+ return (( 1072260.70369 + \
354
+ (1602961601.2090 + \
355
+ ( -6.3706 + \
356
+ ( 0.006593 + \
357
+ ( -0.00003169) \
358
+ * jc) * jc) * jc) * jc) % Const::TURNAS) * Const::AS2R
359
+ rescue => e
360
+ raise
361
+ end
362
+
363
+ #=========================================================================
364
+ # Mean longitude of the ascending node of the Moon (IERS 2003)
365
+ #
366
+ # @param: jc (ユリウス世紀)
367
+ # @return: longitude (rad)
368
+ #=========================================================================
369
+ def compute_om_iers2003(jc)
370
+ return (( 450160.398036 + \
371
+ (-6962890.5431 + \
372
+ ( 7.4722 + \
373
+ ( 0.007702 + \
374
+ ( -0.00005939) \
375
+ * jc) * jc) * jc) * jc) % Const::TURNAS) * Const::AS2R
376
+ rescue => e
377
+ raise
378
+ end
379
+
380
+ #=========================================================================
381
+ # Mean anomaly of the Moon (MHB2000)
382
+ #
383
+ # @param: jc (ユリウス世紀)
384
+ # @return: longitude (rad)
385
+ #=========================================================================
386
+ def compute_l_mhb2000(jc)
387
+ return (2.35555598 + 8328.6914269554 * jc) % Const::PI2
388
+ rescue => e
389
+ raise
390
+ end
391
+
392
+ #=========================================================================
393
+ # Mean longitude of the Moon minus that of the ascending node (MHB2000)
394
+ #
395
+ # @param: jc (ユリウス世紀)
396
+ # @return: longitude (rad)
397
+ #=========================================================================
398
+ def compute_f_mhb2000(jc)
399
+ return (1.627905234 + 8433.466158131 * jc) % Const::PI2
400
+ rescue => e
401
+ raise
402
+ end
403
+
404
+ #=========================================================================
405
+ # Mean elongation of the Moon from the Sun (MHB2000)
406
+ #
407
+ # @param: jc (ユリウス世紀)
408
+ # @return: longitude (rad)
409
+ #=========================================================================
410
+ def compute_d_mhb2000_2(jc)
411
+ return (5.198466741 + 7771.3771468121 * jc) % Const::PI2
412
+ rescue => e
413
+ raise
414
+ end
415
+
416
+ #=========================================================================
417
+ # Mean longitude of the ascending node of the Moon (MHB2000)
418
+ #
419
+ # @param: jc (ユリウス世紀)
420
+ # @return: longitude (rad)
421
+ #=========================================================================
422
+ def compute_om_mhb2000(jc)
423
+ return (2.18243920 - 33.757045 * jc) % Const::PI2
424
+ rescue => e
425
+ raise
426
+ end
427
+
428
+ #=========================================================================
429
+ # General accumulated precession in longitude (IERS 2003)
430
+ #
431
+ # @param: jc (ユリウス世紀)
432
+ # @return: longitude (rad)
433
+ #=========================================================================
434
+ def compute_pa_iers2003(jc)
435
+ return (0.024381750 + 0.00000538691 * jc) * jc
436
+ rescue => e
437
+ raise
438
+ end
439
+
440
+ #=========================================================================
441
+ # Mercury longitudes (IERS 2003)
442
+ #
443
+ # @param: jc (ユリウス世紀)
444
+ # @return: longitude (rad)
445
+ #=========================================================================
446
+ def compute_lme_iers2003(jc)
447
+ return (4.402608842 + 2608.7903141574 * jc) % Const::PI2
448
+ rescue => e
449
+ raise
450
+ end
451
+
452
+ #=========================================================================
453
+ # Venus longitudes (IERS 2003)
454
+ #
455
+ # @param: jc (ユリウス世紀)
456
+ # @return: longitude (rad)
457
+ #=========================================================================
458
+ def compute_lve_iers2003(jc)
459
+ return (3.176146697 + 1021.3285546211 * jc) % Const::PI2
460
+ rescue => e
461
+ raise
462
+ end
463
+
464
+ #=========================================================================
465
+ # Earth longitudes (IERS 2003)
466
+ #
467
+ # @param: jc (ユリウス世紀)
468
+ # @return: longitude (rad)
469
+ #=========================================================================
470
+ def compute_lea_iers2003(jc)
471
+ return (1.753470314 + 628.3075849991 * jc) % Const::PI2
472
+ rescue => e
473
+ raise
474
+ end
475
+
476
+ #=========================================================================
477
+ # Mars longitudes (IERS 2003)
478
+ #
479
+ # @param: jc (ユリウス世紀)
480
+ # @return: longitude (rad)
481
+ #=========================================================================
482
+ def compute_lma_iers2003(jc)
483
+ return (6.203480913 + 334.0612426700 * jc) % Const::PI2
484
+ rescue => e
485
+ raise
486
+ end
487
+
488
+ #=========================================================================
489
+ # Jupiter longitudes (IERS 2003)
490
+ #
491
+ # @param: jc (ユリウス世紀)
492
+ # @return: longitude (rad)
493
+ #=========================================================================
494
+ def compute_lju_iers2003(jc)
495
+ return (0.599546497 + 52.9690962641 * jc) % Const::PI2
496
+ rescue => e
497
+ raise
498
+ end
499
+
500
+ #=========================================================================
501
+ # Saturn longitudes (IERS 2003)
502
+ #
503
+ # @param: jc (ユリウス世紀)
504
+ # @return: longitude (rad)
505
+ #=========================================================================
506
+ def compute_lsa_iers2003(jc)
507
+ return (0.874016757 + 21.3299104960 * jc) % Const::PI2
508
+ rescue => e
509
+ raise
510
+ end
511
+
512
+ #=========================================================================
513
+ # Uranus longitudes (IERS 2003)
514
+ #
515
+ # @param: jc (ユリウス世紀)
516
+ # @return: longitude (rad)
517
+ #=========================================================================
518
+ def compute_lur_iers2003(jc)
519
+ return (5.481293872 + 7.4781598567 * jc) % Const::PI2
520
+ rescue => e
521
+ raise
522
+ end
523
+
524
+ #=========================================================================
525
+ # Neptune longitude (MHB2000)
526
+ #
527
+ # @param: jc (ユリウス世紀)
528
+ # @return: longitude (rad)
529
+ #=========================================================================
530
+ def compute_lne_mhb2000(jc)
531
+ return (5.321159000 + 3.8127774000 * jc) % Const::PI2
532
+ rescue => e
533
+ raise
534
+ end
535
+
536
+ #=========================================================================
537
+ # 回転行列(x 軸中心)
538
+ #
539
+ # @param: phi (回転量(rad))
540
+ # @param: r (回転行列)
541
+ # @return: r_a (回転後)
542
+ #=========================================================================
543
+ def r_x(phi, r = Const::R_UNIT)
544
+ r_a = Array.new
545
+
546
+ begin
547
+ s, c = Math.sin(phi), Math.cos(phi)
548
+ a10 = c * r[1][0] + s * r[2][0]
549
+ a11 = c * r[1][1] + s * r[2][1]
550
+ a12 = c * r[1][2] + s * r[2][2]
551
+ a20 = - s * r[1][0] + c * r[2][0]
552
+ a21 = - s * r[1][1] + c * r[2][1]
553
+ a22 = - s * r[1][2] + c * r[2][2]
554
+ r_a << r[0]
555
+ r_a << [a10, a11, a12]
556
+ r_a << [a20, a21, a22]
557
+ return r_a
558
+ rescue => e
559
+ raise
560
+ end
561
+ end
562
+
563
+ #=========================================================================
564
+ # 回転行列(y 軸中心)
565
+ #
566
+ # @param: theta (回転量(rad))
567
+ # @param: r (回転行列)
568
+ # @return: r_a (回転後)
569
+ #=========================================================================
570
+ def r_y(theta, r = Const::R_UNIT)
571
+ r_a = Array.new
572
+
573
+ begin
574
+ s, c = Math.sin(theta), Math.cos(theta)
575
+ a00 = c * r[0][0] - s * r[2][0]
576
+ a01 = c * r[0][1] - s * r[2][1]
577
+ a02 = c * r[0][2] - s * r[2][2]
578
+ a20 = s * r[0][0] + c * r[2][0]
579
+ a21 = s * r[0][1] + c * r[2][1]
580
+ a22 = s * r[0][2] + c * r[2][2]
581
+ r_a << [a00, a01, a02]
582
+ r_a << r[1]
583
+ r_a << [a20, a21, a22]
584
+ return r_a
585
+ rescue => e
586
+ raise
587
+ end
588
+ end
589
+
590
+ #=========================================================================
591
+ # 回転行列(z 軸中心)
592
+ #
593
+ # @param: psi (回転量(rad))
594
+ # @param: r (回転行列)
595
+ # @return: r_a (回転後)
596
+ #=========================================================================
597
+ def r_z(psi, r = Const::R_UNIT)
598
+ r_a = Array.new
599
+
600
+ begin
601
+ s, c = Math.sin(psi), Math.cos(psi)
602
+ a00 = c * r[0][0] + s * r[1][0];
603
+ a01 = c * r[0][1] + s * r[1][1];
604
+ a02 = c * r[0][2] + s * r[1][2];
605
+ a10 = - s * r[0][0] + c * r[1][0];
606
+ a11 = - s * r[0][1] + c * r[1][1];
607
+ a12 = - s * r[0][2] + c * r[1][2];
608
+ r_a << [a00, a01, a02]
609
+ r_a << [a10, a11, a12]
610
+ r_a << r[2]
611
+ return r_a
612
+ rescue => e
613
+ raise
614
+ end
615
+ end
616
+
617
+ #=========================================================================
618
+ # 座標回転
619
+ #
620
+ # @param: r (回転行列)
621
+ # @param: pos (回転前直角座標)
622
+ # @return: pos_r (回転後直角座標)
623
+ #=========================================================================
624
+ def rotate(r, pos)
625
+ return (0..2).map do |i|
626
+ (0..2).inject(0) { |sum, j| sum + r[i][j] * pos[j] }
627
+ end
628
+ rescue => e
629
+ raise
630
+ end
631
+ end
632
+ end
633
+