Celestia/Celx 指令碼/CELX Lua 方法/CEL 命令 gotolonglat
外觀
gotolonglat { time <持續時間> distance <半徑距離> up <向上向量> longitude <經度數值> latitude <緯度數值> }
移動到當前選定的物體,花費 <持續時間> 秒,在距離物體 <半徑距離> 處停止,使用 <向上向量> 方向,將自己定位在指定的經度 <經度數值> 和緯度 <緯度數值> 表面座標上方。
注意:gotolonglat 命令不會重置座標系。它保留先前設定的座標系。
引數
- time <持續時間>
- 移動到物體的秒數。預設值為 1.0 秒。
- distance <半徑距離>
- 描述您希望定位到物體多遠,以物體的半徑為單位,加 1。預設值為 5.0。
特殊的 <距離> 值為- 0(零)是物體的中心。
注意:在 1.3.1 版本中,使用此值會導致程式錯誤地識別後續定位值,因此請勿使用零。 - 1 是物體的表面。
注意:移動到物體的精確表面級別可能會導致某些顯示卡在顯示屏上顯示隨機多邊形,因此最好使用略高於表面的值。
- 0(零)是物體的中心。
- up <向上向量>
- 定義哪個軸向上,X [1 0 0],Y [0 1 0] 或 Z [0 0 1]。預設值為 [0 1 0]。
- longitude <經度數值>
- 此值描述您希望定位到的經度表面座標,應以度為單位指定為十進位制值。無預設值。
經度對於西半球指定為負數,對於東半球指定為正數(“+”號不是必需的)。 - latitude <緯度數值>
- 此值描述您希望定位到的緯度表面座標,應以度為單位指定為十進位制值。無預設值。
緯度對於南半球指定為負數,對於北半球指定為正數(“+”號不是必需的)。
CELX 等效
基於 observer:gotolonglat() 方法。
- 找到要前往的名稱為 <字串> 的目標物體並存儲在“objectname”中。
在 CELX 指令碼中,無需選擇“objectname”。
objectname = celestia:find( <string> )
- 確定“objectname”的半徑並存儲在“radius”中。
radius = objectname:radius()
- 確定以公里為單位的移動距離:<半徑距離> * “radius” 並存儲在“distance”中。
distance = <radiusdistance> * radius
- 將 <經度數值> 和 <緯度數值> 從度轉換為弧度,方法是將度數乘以 math.pi(= 3.14159265)併除以 180。Lua 的“math.rad()”函式也可以用於此。
longitude = math.rad( <longnumber> ) latitude = math.rad( <latnumber> )
- 定義一個向量物件,以確定哪個軸向上。
upaxis = celestia:newvector( <upvector> )
- 獲取活動檢視的觀察者例項,並轉到在確定距離“distance”處位於“objectname”表面上的“longitude”和“latitude”表面座標,時間為 <持續時間> 秒。
- 如果沒有給出 <持續時間>,則預設時間為 5.0 秒!!!
- 如果沒有給出 <距離>,則預設為物體半徑的 5 倍。
- 如果沒有給出 <經度>,則預設為 0。
- 如果沒有給出 <緯度>,則預設為 0。
- 如果沒有給出 <向上向量>,則預設為 (0,1,0) -> Y。
obs = celestia:getobserver() obs:gotolonglat(objectname, longitude, latitude, distance, <duration>, upaxis )
- 等待 <持續時間> 秒。
wait( <duration> )
總結
objectname = celestia:find( <string> ) radius = objectname:radius() distance = <radiusdistance> * radius longitude = math.rad( <longnumber> ) latitude = math.rad( <latnumber> ) upaxis = celestia:newvector( <upvector> ) obs = celestia:getobserver() obs:gotolonglat(objectname, longitude, latitude, distance, <duration>, upaxis ) wait( <duration> )
示例
此示例選擇地球並將攝像機定位在美國華盛頓州西雅圖上空。
CEL
select { object "Sol/Earth" }
synchronous { }
gotolonglat { time 5 distance 3 up [0 1 0] longitude -122 latitude 47 }
print { text "Traveling to Seattle, Washington, USA."
row -3 column 1 duration 5 }
wait { duration 5 }
print { text "Hovering over Seattle, Washington, USA."
row -3 column 1 duration 5 }
wait { duration 5 }
使用 observer:gotolonglat() 方法的CELX
earth = celestia:find("Sol/Earth")
celestia:select(earth)
obs = celestia:getobserver()
obs:synchronous(earth)
earthradius = earth:radius()
earthdistance = 3 * earthradius
longitude = -122 * math.pi/180
latitude = 47 * math.pi/180
upaxis = celestia:newvector(0,1,0)
obs:gotolonglat(earth, longitude, latitude, earthdistance, 5.0, upvector)
celestia:print("Traveling to Seattle, Washington, USA.", 5.0, -1, -1, 1, 3)
wait(5.0)
celestia:print("Hovering over Seattle, Washington, USA.", 5.0, -1, -1, 1, 3)
wait(5.0)