跳轉到內容

Celestia/Celx 指令碼/CELX Lua 方法/Celx 階段

來自華夏公益教科書,自由的教科書

Celx 指令碼: 階段

[編輯 | 編輯原始碼]

1.6.0 階段類在 Celestia 版本 1.6.0 之前不可用。

物件的軌跡被細分為一個或多個階段。
每個階段都有自己的

  • 軌跡;
  • 旋轉模型;
  • 軌道座標系;
  • 本體座標系。

可以透過兩種方式獲取物件的階段

  • 使用 1.6.0 object:getphase() 方法,該方法返回指定時間的活動階段,或者
  • 使用 1.6.0 object:phases() 方法,該方法返回物件時間軸中所有階段的迭代器。

示例
惠更斯探測器的軌跡可能包含三個階段

  1. 附著在卡西尼號上
    • 卡西尼號的本體固定座標系;
    • 軌跡只是一個固定位置。
  2. 分離後的自由飛行
    • 以土星為中心的座標系;
    • 來自 xyz 檔案或 SPICE 的軌跡
  3. 在泰坦表面 (Celestia 1.6.0 中尚未實現)
    • 泰坦固定座標系;
    • 軌跡是一個固定位置。

本章包含所有可用的階段方法列表,這些方法可用於 "階段" 物件。

時間跨度

[編輯 | 編輯原始碼]

1.6.0 數字, 數字 phase:timespan()

返回此時間軸階段的開始時間和結束時間,以兩個 TDB (質心動力學時間) 儒略日數字表示。

注意

  1. 階段的開始時間始終等於前一階段的結束時間。
  2. 對於在任何時間都有效的階段,開始時間和結束時間將分別等於特殊浮點數 -infinity 和 +infinity。
  3. TDB 時間尺度與更常見的 UTC 略有不同。透過使用 TDB,Celestia 可以更準確地放置物體。截至 2008 年 1 月 1 日,兩者之間的差約為 65 秒。有關詳細資訊,請參閱 Celestia/時間尺度
  4. 要將 UTC 時間與 TDB 時間相互轉換,可以使用 1.5.0 celestia:utctotdb()1.5.0 celestia:tdbtoutc() 方法。
  5. 要將普通日曆日期與儒略日相互轉換,可以使用 celestia:tojulianday()celestia:fromjulianday() 方法。

示例
檢索卡西尼號時間軸各階段的開始時間和結束時間。

object = celestia:find("Sol/Cassini")
count = 0
for phase in object:phases() do
   count = count + 1
   begintime, endtime = phase:timespan()
   celestia:print("Phase [" .. count .. "] of " .. object:name() .. 
                  "\nStart: " .. begintime .. " End: " .. endtime, 5.0, -1, -1, 2, 4)
   wait(5.0)
end


返回 階段 方法索引。

軌道座標系

[編輯 | 編輯原始碼]

1.6.0 座標系 phase:orbitframe()

返回此時間軸階段的軌道座標系,作為 "座標系" 物件。

示例
顯示惠更斯在從卡西尼號分離後的自由飛行期間的軌道座標系參考物件。

tdbtime = celestia:utctotdb(2005, 01, 01)
celestia:settime(tdbtime)
object = celestia:find("huygens")
celestia:select(object)
phase = object:getphase(tdbtime)
-- Orbit frame
obj_orbf = phase:orbitframe()
object2 = obj_orbf:getrefobject()
-- Goto object and print message
obs = celestia:getobserver()
obs:gotolonglat(object, math.rad(42), math.rad(14), 0.033, 2.0)
celestia:print("Orbit frame reference object during this phase of " ..
               object:name() .. " is: " .. object2:name(), 10.0, -1, -1, 2, 4)
wait(10.0)


返回 階段 方法索引。

本體座標系

[編輯 | 編輯原始碼]

1.6.0 座標系 phase:bodyframe()

返回此時間軸階段的本體座標系,作為 "座標系" 物件。

示例
顯示惠更斯在卡西尼號飛往土星的途中,其飛行的本體座標系參考物件。

tdbtime = celestia:utctotdb(2004, 06, 01)
celestia:settime(tdbtime)
object = celestia:find("huygens")
celestia:select(object)
phase = object:getphase(tdbtime)
-- Body frame
obj_bodyf = phase:bodyframe()
object2 = obj_bodyf:getrefobject()
-- Goto object and print message
obs = celestia:getobserver()
obs:gotolonglat(object, math.rad(42), math.rad(14), 0.033, 2.0)
celestia:print("Body frame reference object during this phase of " ..
               object:name() .. " is: " .. object2:name(), 10.0, -1, -1, 2, 4)
wait(10.0)


返回 階段 方法索引。

獲取位置

[編輯 | 編輯原始碼]

1.6.0 位置 phase:getposition(數字:時間)

返回指定時間的 座標系座標 中的位置,作為 "位置" 物件。

引數

時間
用於確定位置的時間,作為 TDB (質心動力學時間) 儒略日數字表示。
超出階段覆蓋範圍的時間將自動鉗制到範圍的開頭或結尾。

注意

  1. Celestia 中的位置分量 (X,Y,Z) 以光年的百萬分之一儲存。因此,當您希望以公里或英里定義您的位置時,您必須轉換這些位置。因此,您可以使用一個常量,該常量必須先在您的指令碼中初始化
    • 從光年的百萬分之一到公里,使用常數 uly_to_km = 9460730.4725808。
    • 從光年的百萬分之一到英里,使用常數 uly_to_mls = 5912956.5453630。
  2. 接下來,您可以將光年的百萬分之一轉換為公里或英里,如下所示
    • km = 數字:光年的百萬分之一 * uly_to_km
    • miles = 數字:光年的百萬分之一 * uly_to_mls
  3. 可以對 CELX "位置" 物件使用 位置 方法。"位置" 物件也可以在其他方法中使用,這些方法需要 "位置" 物件作為引數。
  4. TDB 時間尺度與更常見的 UTC 略有不同。透過使用 TDB,Celestia 可以更準確地放置物體。截至 2008 年 1 月 1 日,兩者之間的差約為 65 秒。有關詳細資訊,請參閱 Celestia/時間尺度
  5. 要將 UTC 時間與 TDB 時間相互轉換,可以使用 1.5.0 celestia:utctotdb()1.5.0 celestia:tdbtoutc() 方法。
  6. 要將普通日曆日期與儒略日相互轉換,可以使用 celestia:tojulianday()celestia:fromjulianday() 方法。

示例 1
獲取惠更斯在 第一 階段特定時間的 位置。

uly_to_km = 9460730.4725808
tdbtime = celestia:utctotdb(2004, 06, 01)
celestia:settime(tdbtime)
object = celestia:find("huygens")
celestia:select(object)
phase = object:getphase(tdbtime)
obj_posf = phase:getposition(tdbtime)
-- Goto object and print message
obs = celestia:getobserver()
obs:gotolonglat(object, math.rad(42), math.rad(14), 0.033, 2.0)
celestia:print(object:name() .. " frame coordinates at 2004, 06, 01, 00:00:00 hr are:\n" ..
               "X: " .. obj_posf.x*uly_to_km*1000 .. " meter\n" .. 
               "Y: " .. obj_posf.y*uly_to_km*1000 .. " meter\n" ..
               "Z: " .. obj_posf.z*uly_to_km*1000 .. " meter", 10.0, -1, -1, 2, 6)
wait(10.0)

示例 2
獲取惠更斯在 第二 階段特定時間的 位置。

uly_to_km = 9460730.4725808
tdbtime = celestia:utctotdb(2005, 01, 01)
celestia:settime(tdbtime)
object = celestia:find("huygens")
celestia:select(object)
phase = object:getphase(tdbtime)
obj_posf = phase:getposition(tdbtime)
-- Goto object and print message
obs = celestia:getobserver()
obs:gotolonglat(object, math.rad(42), math.rad(14), 0.033, 2.0)
celestia:print(object:name() .. " frame coordinates at 2005, 01, 01, 00:00:00 hr are:\n" ..
               "X: " .. obj_posf.x*uly_to_km .. " km\n" .. 
               "Y: " .. obj_posf.y*uly_to_km .. " km\n" ..
               "Z: " .. obj_posf.z*uly_to_km .. " km", 10.0, -1, -1, 2, 6)
wait(10.0)


返回 階段 方法索引。

獲取方向

[編輯 | 編輯原始碼]

1.6.0 旋轉 phase:getorientation(數字:時間)

返回指定時間的 座標系座標 中的方向,作為 "旋轉" 物件。

引數

時間
用於確定方向的時間,作為 TDB (質心動力學時間) 儒略日數字表示。
超出階段覆蓋範圍的時間將自動鉗制到範圍的開頭或結尾。

注意

  1. 可以對 CELX "旋轉" 物件使用 旋轉 方法。"旋轉" 物件也可以在其他方法中使用,這些方法需要 "旋轉" 物件作為引數。
  2. TDB 時間尺度與更常見的 UTC 略有不同。透過使用 TDB,Celestia 可以更準確地放置物體。截至 2008 年 1 月 1 日,兩者之間的差約為 65 秒。有關詳細資訊,請參閱 Celestia/時間尺度
  3. 要將 UTC 時間與 TDB 時間相互轉換,可以使用 1.5.0 celestia:utctotdb()1.5.0 celestia:tdbtoutc() 方法。
  4. 要將普通日曆日期與儒略日相互轉換,可以使用 celestia:tojulianday()celestia:fromjulianday() 方法。

示例

tdbtime = celestia:utctotdb(2005, 01, 01)
celestia:settime(tdbtime)
object = celestia:find("huygens")
celestia:select(object)
phase = object:getphase(tdbtime)
obj_rotf = phase:getorientation(tdbtime)
...


返回 階段 方法索引。

華夏公益教科書