Closed versvisa closed 2 months ago
It should match up in the vessel.control_frame
.
I suppose this is something of a left-over from KSP1 where cockpit had been tilted by 90 degrees.
Some more testing shows that the body_frame
is directly affected by the VAB/spawn orientation. It can be at any odd angle.
In the control_frame
the values are consistent with the navball. Some testing shows that the body axes are [X,Y,Z] = [right, forward, down] ~[forward, right, down]~. Could this be added to the documentation? I think in KSP1 the axes body were [right, up, forward]. So this is a little sursprising.
This hierarchy of transformation frame is something of a new invention in KSP2, so some inconsistencies are to be expected I guess.
Here is a little test-script for experimentation:
use { Vessel } from ksp::vessel
use { CONSOLE, RED, WHITE } from ksp::console
use { sleep } from ksp::game
use { DEBUG } from ksp::debug
use { vec3 } from ksp::math
pub fn main_flight(vessel: Vessel) -> Result<Unit, string> = {
CONSOLE.clear()
CONSOLE.print_line($"Time: {current_time()}")
DEBUG.add_vector(fn() -> vessel.global_position, fn() -> vec3(0,10,0).to_global(vessel.body_frame), RED, "up1", 2)
DEBUG.add_vector(fn() -> vessel.global_position, fn() -> vec3(0,10,0).to_global(vessel.control_frame), WHITE, "up2", 2)
sleep(10000) // Just keep the vectors up for a while
}
From what I can tell:
vec3(0,1,0)
in the control_frame should generally point in the "go"-direction of the vessel (unless you put the engine up-side down ;) )vec3(0,1,0)
in the body_frame (an I guess the celestical_frame as well) should generally point up-ward from the launch site
Hello, there seems to be some inconsistency in body coordinate systems. The following screenshots show the output of this code
In each case the vessel is oriented such that north, east and up are lined up with body-X, body-Y and body-Z respectively. Thus, according to KS2 they are in the same orientation. But according to the navball and 3D visual they are in different orientations.