Class: When::Coordinates::Spatial

Inherits:
BasicTypes::Object show all
Includes:
Ephemeris
Defined in:
lib/when_exe/coordinates.rb

Overview

空間位置

Defined Under Namespace

Modules: Normalize

Constant Summary collapse

LabelProperty =
'label'
DEGREE =

Degree / Internal Location Unit(16“)

(3600 
225
ECLIPTIC =

黄道座標 (ecliptic coordinate system)

0
EQUATORIAL =

赤道座標 (equatorial coordinate system)

1
EQUATORIAL_HA =

赤道座標 (equatorial coordinate system with hour angle)

2
HORIZONTAL =

地平座標 (horizontal coordinate system)

3
CENTER =

惑星中心の高度

:center

Constants included from Ephemeris

Ephemeris::AU, Ephemeris::AcS, Ephemeris::BCENT, Ephemeris::C0, Ephemeris::CIRCLE, Ephemeris::COS, Ephemeris::COSL, Ephemeris::COSLT, Ephemeris::COST, Ephemeris::DAY, Ephemeris::DEG, Ephemeris::EPOCH1800, Ephemeris::EPOCH1900, Ephemeris::EPOCH1975, Ephemeris::EPOCH2000, Ephemeris::FARAWAY, Ephemeris::JCENT, Ephemeris::JYEAR, Ephemeris::Jupiter, Ephemeris::LIN, Ephemeris::Mars, Ephemeris::Mercury, Ephemeris::Neptune, Ephemeris::P0B, Ephemeris::P0L, Ephemeris::P0P, Ephemeris::P0dB, Ephemeris::P0dL, Ephemeris::P1B, Ephemeris::P1L, Ephemeris::P1R, Ephemeris::P2B, Ephemeris::P2L, Ephemeris::P2Q, Ephemeris::P2dL, Ephemeris::P3L, Ephemeris::P3Q, Ephemeris::P4B, Ephemeris::P4L, Ephemeris::P4Q, Ephemeris::P4dL, Ephemeris::P5B, Ephemeris::P5L, Ephemeris::P5Q, Ephemeris::P5dL, Ephemeris::P5l, Ephemeris::P5n, Ephemeris::P5r, Ephemeris::P5t, Ephemeris::P6B, Ephemeris::P6L, Ephemeris::P6Q, Ephemeris::P6dL, Ephemeris::P6l, Ephemeris::P6n, Ephemeris::P6r, Ephemeris::P6t, Ephemeris::P7B, Ephemeris::P7L, Ephemeris::P7R, Ephemeris::P8B, Ephemeris::P8L, Ephemeris::P8R, Ephemeris::P9B, Ephemeris::P9L, Ephemeris::P9R, Ephemeris::PSEC, Ephemeris::Pluto, Ephemeris::SIN, Ephemeris::SINL, Ephemeris::SINLT, Ephemeris::SINT, Ephemeris::Saturn, Ephemeris::Uranus, Ephemeris::Venus

Instance Attribute Summary collapse

Attributes inherited from BasicTypes::Object

#label

Attributes included from Parts::Resource

#_pool, #child, #keys, #locale, #namespace

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Ephemeris

_adjust, _rot, _to_p2, _to_p3, _to_r3, acos, asin, cosc, cosd, delta_e, delta_p, julian_century_from_2000, julian_year_from_1975, obl, polynomial, root, sinc, sind, tanc, tand, trigonometric

Methods included from Parts::Resource

#[], #^, _decode, _encode, _extract_prefix, _instance, _parse, _path_with_prefix, _replace_tags, #each, #enum_for, #hierarchy, #include?, #included?, #iri, #leaf?, #m17n, #map, #next, #parent, #prev, #registered?

Methods included from Parts::Resource::Pool

#[], #[]=, #_pool, #_setup_, #pool_keys

Methods included from Parts::Resource::Synchronize

#synchronize

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object (private)

その他のメソッド

When::Coordinates::Spatial 


1449
1450
1451
1452
1453
1454
1455
1456
# File 'lib/when_exe/coordinates.rb', line 1449

def method_missing(name, *args, &block)
  self.class.module_eval %Q{
    def #{name}(*args, &block)
      @datum.send("#{name}", *args, &block)
    end
  } unless When::Parts::MethodCash.escape(name)
  @datum.send(name, *args, &block)
end

Instance Attribute Details

#altNumeric, :Center (readonly)

高度 / m

Returns:

  • (Numeric)
  • (:Center)

    天体の中心の場合



1317
1318
1319
# File 'lib/when_exe/coordinates.rb', line 1317

def alt
  @alt
end

#datumWhen::Ephemeris::Datum (readonly)

座標系



1323
1324
1325
# File 'lib/when_exe/coordinates.rb', line 1323

def datum
  @datum
end

#latNumeric (readonly)

北緯を正とする緯度 / 16秒

Returns:



1304
1305
1306
# File 'lib/when_exe/coordinates.rb', line 1304

def lat
  @lat
end

#longNumeric (readonly)

東経を正とする経度 / 16秒

Returns:



1310
1311
1312
# File 'lib/when_exe/coordinates.rb', line 1310

def long
  @long
end

#refString (readonly)

参照

Returns:



1329
1330
1331
# File 'lib/when_exe/coordinates.rb', line 1329

def ref
  @ref
end

#tzTZInfo::CountryTimezone (readonly)

時間帯(オプショナル)

Returns:

  • (TZInfo::CountryTimezone)

    TZInfoライブラリから経緯度を取得して使用する



1337
1338
1339
# File 'lib/when_exe/coordinates.rb', line 1337

def tz
  @tz
end

Class Method Details

._setup_(location = nil) ⇒ void

Note:

本メソッドでマルチスレッド対応の管理変数の初期化を行っている。 このため、本メソッド自体はスレッドセーフでない。

This method returns an undefined value.

When::Coordinates::Spatial のグローバルな設定を行う

Parameters:



1223
1224
1225
1226
1227
# File 'lib/when_exe/coordinates.rb', line 1223

def _setup_(location=nil)
  @_lock_ = Mutex.new if When.multi_thread
  @_pool  = {}
  @default_location = location
end

.default_locationWhen::Coordinates::Spatial

デフォルトの空間位置を読みだす



1251
1252
1253
# File 'lib/when_exe/coordinates.rb', line 1251

def default_location
  _default_location[1]
end

.default_location=(local) ⇒ When::Coordinates::Spatial, String

Note:

@default_locationは、原則、ライブラリ立ち上げ時に setup で初期化する。 以降、@default_locationに代入を行っても、すでに生成した When::TM::TemporalPosition 等には反映されない。

デフォルトの空間位置

Parameters:

Returns:



1239
1240
1241
1242
1243
1244
1245
# File 'lib/when_exe/coordinates.rb', line 1239

def default_location=(local)
  if @_pool
    @default_location = local
  else
    _setup_(local)
  end
end

.is_default_location_derived?true, false

デフォルトの空間位置が When::TM::Clock のローカルタイムから生成されたか?

Returns:

  • (true, false)


1259
1260
1261
1262
# File 'lib/when_exe/coordinates.rb', line 1259

def is_default_location_derived?
  location = _default_location
  location[0] && location[1]
end

Instance Method Details

#_coords(t) ⇒ Numeric

観測地の日心三次元座標(黄道座標)

Parameters:

Returns:



1389
1390
1391
1392
# File 'lib/when_exe/coordinates.rb', line 1389

def _coords(t)
  t   = +t
  @datum._coords(t) + _coords_diff(t)
end

#horizonNumeric

観測地での‘大地’の視半径

Returns:



1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
# File 'lib/when_exe/coordinates.rb', line 1352

def horizon
  # 地面以下なら 90度とみなす
  return 0.25 if @alt == :Center || @alt <= 0

  # 観測地の地心距離 / m
  r = obserber_distance * 1000.0

  # 大気効果
  air_effect = @datum.air[1] * @alt / (@datum.air[2] * @alt + r)

  # ‘大地’の視半径
  asin((1.0+air_effect) * r / (r+@alt)) / CIRCLE
end

#local_sidereal_time(t) ⇒ Numeric

観測地の地方恒星時 / 時を返します。

Parameters:

Returns:



1373
1374
1375
1376
1377
1378
1379
1380
# File 'lib/when_exe/coordinates.rb', line 1373

def local_sidereal_time(t)
  t = +t
  c = julian_century_from_2000(t)
  result  = @datum.sid[0] + c * (@datum.sid[1] + c * @datum.sid[2]) + @long / (15.0 * DEGREE)
  result += (cosc(obl(c)) * delta_p(c) +
             (t-When::TimeStandard.delta_t_observed(t)/86400+0.5) % 1) * 24 if @datum.kind_of?(Earth)
  result
end

#obserber_distanceNumeric

観測地の地心距離 / kmを返します。

Returns:



1343
1344
1345
1346
# File 'lib/when_exe/coordinates.rb', line 1343

def obserber_distance
  l = PI / (90 * DEGREE) * @lat
  @datum.surface_radius * (@datum.shape[0]+@datum.shape[1]*cos(l)+@datum.shape[2]*cos(2*l))
end