2018-07-27 17:23:38 +02:00
|
|
|
@LAZYGLOBAL OFF.
|
|
|
|
|
2018-07-19 14:42:03 +02:00
|
|
|
// Define actual_prograde, which automatically switches from SHIP:SRFPROGRADE to SHIP:PROGRADE
|
|
|
|
local function set_actual_prograde {
|
|
|
|
if NAVMODE = "SURFACE" {
|
|
|
|
print "Switched actual_prograde to surface SRFPROGRADE".
|
2018-08-05 19:40:16 +02:00
|
|
|
lock actual_prograde to SHIP:srfprograde.
|
2018-07-19 14:42:03 +02:00
|
|
|
} else {
|
|
|
|
print "Switched actual_prograde to orbit PROGRADE".
|
2018-08-05 19:40:16 +02:00
|
|
|
lock actual_prograde to SHIP:prograde.
|
2018-07-19 14:42:03 +02:00
|
|
|
}
|
|
|
|
return true. // preserve trigger
|
|
|
|
}
|
|
|
|
on NAVMODE {return set_actual_prograde().}
|
|
|
|
set_actual_prograde().
|
|
|
|
|
|
|
|
|
2019-02-08 22:19:26 +01:00
|
|
|
function vdraw {
|
2019-02-12 23:33:17 +01:00
|
|
|
//
|
|
|
|
// Wrapper for the VECDRAW-function that doesn't hide the vector by default.
|
|
|
|
//
|
2019-02-09 21:18:47 +01:00
|
|
|
parameter start. // vector or function. For example, pass {return UP:vector.} to automatically update the draw
|
|
|
|
parameter vector. // same as start
|
2019-02-08 22:19:26 +01:00
|
|
|
parameter color is RED.
|
2019-02-09 21:18:47 +01:00
|
|
|
parameter label is "".
|
2019-02-12 23:33:17 +01:00
|
|
|
parameter scale is 1.0.
|
|
|
|
parameter width is 0.2.
|
2019-02-08 22:19:26 +01:00
|
|
|
|
2019-02-12 23:33:17 +01:00
|
|
|
return vecdraw(
|
2019-02-08 22:19:26 +01:00
|
|
|
start,
|
|
|
|
vector,
|
|
|
|
color,
|
2019-02-09 21:18:47 +01:00
|
|
|
label,
|
2019-02-12 23:33:17 +01:00
|
|
|
scale,
|
|
|
|
true, // show
|
|
|
|
width
|
2019-02-08 22:19:26 +01:00
|
|
|
).
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-02-12 23:33:17 +01:00
|
|
|
function ship_raw_to_ship_control {
|
|
|
|
//
|
|
|
|
// Translate a vector in SHIP-RAW coordinates to one in SHIP-CONTROL (STARBOARD, TOP, FORE) coordinates.
|
|
|
|
//
|
|
|
|
parameter vec.
|
|
|
|
|
|
|
|
return V(vdot(vec, FACING:starvector), // projection is correct because SHIP's FACING vectors are normalised
|
|
|
|
vdot(vec, FACING:topvector),
|
|
|
|
vdot(vec, FACING:forevector)). // Same order as SHIP:CONTROL:TRANSLATION's input
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-07-19 14:42:03 +02:00
|
|
|
// ANGLES
|
2018-08-05 19:40:16 +02:00
|
|
|
lock actual_prograde_pitch to vang(actual_prograde:vector, UP:vector).
|
2018-07-19 14:42:03 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2018-07-26 04:06:14 +02:00
|
|
|
// // the following are all vectors, mainly for use in the roll, pitch, and angle of attack calculations
|
|
|
|
// lock rightrotation to ship:facing*r(0,90,0).
|
|
|
|
// lock right to rightrotation:vector. //right and left are directly along wings
|
|
|
|
// lock left to (-1)*right.
|
|
|
|
// lock up to ship:up:vector. //up and down are skyward and groundward
|
|
|
|
// lock down to (-1)*up.
|
|
|
|
// lock fore to ship:facing:vector. //fore and aft point to the nose and tail
|
|
|
|
// lock aft to (-1)*fore.
|
|
|
|
// lock righthor to vcrs(up,fore). //right and left horizons
|
|
|
|
// lock lefthor to (-1)*righthor.
|
|
|
|
// lock forehor to vcrs(righthor,up). //forward and backward horizons
|
|
|
|
// lock afthor to (-1)*forehor.
|
|
|
|
// lock top to vcrs(fore,right). //above the cockpit, through the floor
|
|
|
|
// lock bottom to (-1)*top.
|
|
|
|
|
|
|
|
// // the following are all angles, useful for control programs
|
|
|
|
// lock absaoa to vang(fore,srfprograde:vector). //absolute angle of attack
|
|
|
|
// lock aoa to vang(top,srfprograde:vector)-90. //pitch component of angle of attack
|
|
|
|
// lock sideslip to vang(right,srfprograde:vector)-90. //yaw component of aoa
|
|
|
|
// lock rollangle to vang(right,righthor)*((90-vang(top,righthor))/abs(90-vang(top,righthor))). //roll angle, 0 at level flight
|
|
|
|
// lock pitchangle to vang(fore,forehor)*((90-vang(fore,up))/abs(90-vang(fore,up))). //pitch angle, 0 at level flight
|
|
|
|
// lock glideslope to vang(srfprograde:vector,forehor)*((90-vang(srfprograde:vector,up))/abs(90-vang(srfprograde:vector,up))).
|
|
|
|
// lock ascentangle to vang(srfprograde:vector, forehor). //angle of surface prograde above horizon
|