Celestia/旋轉模型
此頁面上的所有資訊僅與 Celestia 1.5.0 及更高版本相關.
在 v1.5.0 之前,使用單獨的旋轉語句。有關這些宣告的描述,請參見有關 SSC 檔案 的章節。
用法
UniformRotation
{
Period <hours>
Inclination <degrees>
AscendingNode <degrees>
MeridianAngle <degrees>
Epoch <date>
}
週期是物體的恆星自轉週期;也就是說,相對於某個固定背景的自轉。因此,地球的自轉週期將是 23.93 而不是 24 小時。如果未指定週期,則該物體將被潮汐鎖定(即始終對母體顯示相同的面)。
用法
FixedRotation
{
Inclination <degrees>
AscendingNode <degrees>
MeridianAngle <degrees>
}
具有 FixedRotation 的物體將在其參考系內保持恆定的方向。固定旋轉具有與 UniformRotation 相同的屬性,只是不需要自轉週期。
用法
PrecessingRotation
{
Period <hours>
PrecessionPeriod <years>
Inclination <degrees>
AscendingNode <degrees>
MeridianAngle <degrees>
Epoch <date>
}
用法
SampledOrientation <filename>
其中檔名是 Celestia 方向檔案的名稱,按照慣例,該副檔名為 .q(代表四元數)。方向檔案是一個文字檔案,包含一個時間標記的四元數列表。時間是巴里中心動力學時間 (TDB) 中指定的儒略日。檔案中的每條記錄都具有以下形式
<double: Julian Date> <float: w> <float: x> <float: y> <float: z>
其中 w 是實部,x、y 和 z 是四元數的虛部。關於軸 V 的角度為 θ 的旋轉由以下四元數給出:
ScriptedRotation 用於建立旋轉模型,其中方向由 Lua 指令碼檔案中的函式給出。
用法
ScriptedRotation
{
Module <string>
Function <string>
...additional properties...
}
模組給出了將透過 Lua 的 require 方法載入的包的名稱。它在標準路徑列表中搜索具有指定名稱的指令碼檔案。函式是生成一個包含旋轉模型屬性的表的工廠函式的名稱,包括一個返回特定時間方向的函式。除了模組和函式之外的所有 ScriptRotation 屬性都將傳遞給 Lua 函式以建立旋轉物件。函式名是唯一需要的引數。
要建立自己的 ScriptedRotation,您需要熟悉 Celestia 的 celx 指令碼中使用的 Lua 指令碼語言。ScriptedRotation 定義中指定的 Lua 函式是一個工廠函式,它在解析 ScriptedRotation 後立即被呼叫。工廠函式接受一個包含來自 ScriptedRotation 定義的所有屬性的單個表格引數。該函式必須返回一個 Lua 旋轉模型物件,它只是一個包含幾個標準欄位的表格。他們是
- 週期 - 一個以天為單位給出旋轉週期的數字。如果不存在,則假定旋轉是非週期性的。
- beginDate、endDate - 可選值,用於指定旋轉模型有效的時段。如果未給出,則假定旋轉模型可在任何時間使用。end < begin 的旋轉模型是不允許的。
- orientation(time) - 位置函式以時間值(TDB 儒略日)作為輸入,並返回四個值,這些值是四元數 (w, x, y, z)。此四元數與軸角旋轉 (A, θ) 相關聯,方法是
, , ,
以下是如何在 .ssc 檔案中使用 ScriptedRotation 的示例
"Scripted" "Sol/Earth"
{
ScriptedRotation
{
Module "rotations"
Function "wobble"
Period 1
Amplitude 180
}
}
上面的 ssc 片段告訴 Celestia 載入名為 rotations.lua 的檔案並呼叫名為 wobble 的函式以建立一個新的旋轉模型物件。其餘屬性都將作為表格的欄位傳遞給 wobble 函式。接下來是 rotations.lua 的內容
-- prototype for the wobble scripted rotation has default values for
-- any parameters that are omitted in the ssc file.
wobbleproto =
{
Amplitude = 0,
Period = 1,
}
-- constructor method
function wobbleproto:new(o)
o = o or {} -- create table if one not provided
setmetatable(o, self)
self.__index = self
-- set the period to whatever value was specified in the ssc file;
-- slightly confusing because Celestia is case sensitive--period must
-- be lowercase, but the field from the ssc file is capitalized.
o.period = o.Period
return o
end
-- The orientation function. This implementation produces a back and forth
-- wobble of Amplitude degrees about the z axis.
function wobbleproto:orientation(tjd)
local t = tjd - 2451545.0
local theta = self.Amplitude * math.sin((t / self.Period + 0) * math.pi * 2);
-- convert from degrees to radians
theta = theta * math.pi / 180
-- compute a quaternion representing the orientation
return math.cos(theta / 2), 0, 0, math.sin(theta / 2)
end
function wobble(sscvals)
-- create a new wobble rotation object
return wobbleproto:new(sscvals)
end
ScriptedRotations 有一些限制。唯一允許的引數是簡單型別:字串、數字和布林值。諸如陣列和屬性列表之類的複雜型別將不會傳遞給 Lua 工廠函式。此限制可能會在 Celestia 的未來版本中消失。此外,Celestia 預計方向函式始終會針對相同的時間值返回相同的方向。
1.6.0
用法
SpiceRotation
{
Kernel <string|string array> # optional
Frame <string>
BaseFrame <string> # optional (defaults to ecliptic)
Period <number> # optional (units are hours)
Beginning <number> # optional
Ending <number> # optional
}
SpiceRotation 用於將來自 NASA SPICE 系統的方位資訊匯入 Celestia。Celestia 物件的方位將鎖定到 SPICE 座標系。
並非所有版本的 Celestia 都支援 SPICE。SpiceRotation 在 1.6.0 之前的 Celestia 版本中不受支援。
Kernel 屬性可用於指定要載入的一個或多個 SPICE 核心 (SPK) 檔案的名稱。如果所有必需的核心檔案都在先前載入的物件的定義中列出,則可以省略它。Celestia 期望核心檔案位於附加元件的資料目錄中。
Frame 和 BaseFrame 是字串,它們提供座標系的 SPICE 名稱。SpiceRotation 的方位是座標系相對於基座標系的方位。如果未指定基座標系,則預設為 eclipj2000。基座標系應與 Celestia 物件的 BodyFrame 的 SPICE 等效項一致。
Beginning 和 Ending 指定 SPICE 旋轉的有效時間範圍。如果省略 Beginning 和 Ending,則假設旋轉模型在任何時間都有效。指定 Beginning 而沒有 Ending 或反之則為錯誤。
Period 指定主旋轉週期;預設為 0,表示旋轉是非週期的。提供旋轉週期並不重要;它僅由 Celestia 用於顯示諸如恆星日長度之類的物件資訊。
示例
# Use the frame IAU_EARTH as defined by the constants in the SPICE text kernel pck00008.tpc
SpiceRotation
{
Kernel "pck00008.tpc"
Frame "IAU_EARTH"
BaseFrame "eclipj2000"
Period 23.9344694
}