Pitch/Yaw/Roll Function

Issue #204 resolved
Justagai created an issue

Thanks to RandomStarfighter for gathering this info.

Pitch:

Shiplist Pitch * 0.09 = Joystick pitch per frame 65535 / Joystick Pitch per frame = total frames for full 360 degree rotation total frames * 32 ms per frame = total time (realtime) for full rotation

X-W: 6.06 seconds Y-W: 7 A-W: 5.7 B-W: 6.5

Yaw with no roll applied:

For yaw, using the no-pitch patch, the formula is the same except the starting shiplist yaw is divided by 3.1

Shiplist Yaw / 3.1 * 0.09 = Joystick yaw per frame X-W: 5.15 seconds for full yaw rotation Y-W: 8.16 A-W: 4.73 B-W: 6.3

Yaw with roll applied:

For a rolling yaw, the formula doesn't properly calculate the amount of change per frame because it rolls in a circular sine pattern rather than linear, and affects two axes. However the total amount of time it takes to yaw/roll in a full circle back to the starting point does follow the formula. Shiplist Yaw / 2.175 * 0.09 = total delta per frame?

X-W: 3.62 seconds for full circle Y-W: 5.70 A-W: 3.32 B-W: 4.43

Pure Roll

A pure roll is based off yaw, but capped no higher than 12288. Shiplist Yaw * 0.084 = delta per frame

X-W: 2.21 seconds for full circle Y-W: 3.48 A-W: 2.03 B-W: 2.70

As with the other numbers for pitch/yaw, these are all estimations but are very close to the observed times, usually within 20-40 milliseconds.

Yaw/Pitch Shiplist values:

Yaw Hardcoded Limit: 12288 Pitch Hardcoded Limit: 4096

X-wing: Yaw - 11264 Pitch - 3840

Ywing: Yaw - 7168 Pitch - 3328

Awing: Yaw: 15360 Pitch: 4608

TIE Fighter: Yaw - 12288 Pitch - 5120

TIE Interceptor: Yaw - 12800 Pitch - 5632

TIE Bomber: Yaw - 12800 Pitch - 4352

Assault Gunboat: Yaw - 16384 Pitch - 3840

Transport Yaw - 5120 Pitch - 3328

Shuttle Yaw - 10240 Pitch - 3328

Tug: Yaw - 11264 Pitch - 6144

Container Yaw - 11264 Pitch - 3840

Freighter Yaw - 4608 Pitch - 2048

Calamari Cruiser Yaw - 2048 Pitch - 512

Nebulon B Frigate Yaw - 2048 Pitch - 512

Corellian Corvette Yaw - 6144 Pitch - 1024

Star Destroyer Yaw - 2048 Pitch - 512

TIE Advanced: Yaw - 12800 Pitch - 6144

B-wing: Yaw - 9216 Pitch - 3584

Comments (9)

  1. Justagai reporter

    Something that's bothering me is the Nebulon B Frigate's yaw. I'm going to do some research as to why it can yaw even though its set to 0.

  2. Justagai reporter

    I have uploaded videos of the AI when its yaw is set to 0, as well as pitch and other variations. Its located in my onedrive\Issues#204

    The AI is given leeway on pitch and yaw, but pitch is absolutely important for it to target things and move in an intentional direction. This is why the Nebulon B can get away with having its Yaw set to 0 (it would not function otherwise if its pitch was set to 0).

    EDIT: Why did the developers go this route with the Nebulon B? The only thing I can think of is to prevent it from rolling when adjusting course. Interestingly, the ISD, CRS and CRV and any ship with a starship order will roll a bit when facing its waypoint and it needs to adjust its course. Maybe the Nebulon B would look weird when rolling?

  3. Justagai reporter

    I'm completely wrong here on the Nebulon B Yaw/pitch values. I was not able to get the proper values because it would crash when I played as it, so I got the values when it was an AI instead. It's possible that either its offset shifted which is why I thought the yaw was 0, or the offset to the right of the pitch is looked at if yaw is 0? This is the only ship that does this. I have updated the values accordingly on the Nebulon B Frigate.

  4. Random

    I finally finished the next round of testing using vJoy for input feeding. These readings contain far more samples, and appear to be accurate with manual control.

    This formula calculates the total time (in milliseconds) to complete a full rotation on a specific axis.

    (65535 / (AxisValue * AxisMult * YawMult * RealTimeMult)) * 32

    The delta per frame consists of several combined multipliers.

    AxisValue: either the craft's Pitch or Yaw, depending on calculation. There is no value for roll, it uses yaw instead. Note that pitch and yaw are capped to maximum of 4096 and 12288 respectively. This cap can be observed for the A-wing and TIEs.

    AxisMult: Will be either 0.1 for pitch, 0.04 for yaw, or 0.08 for roll.

    RollMult: SPECIAL CASE. Only included when performing a yaw. This value is exactly sqrt(2), or ~1.4142. This is part of a rolling yaw, which the game uses for player craft.

    RealTimeMult: (optional!) The in-game timer runs faster than real-time. Include this multiplier to get the actual time in real-time. This constant was estimated to be around 1.0484775, based on an overall best-fit to closely match the values collected from my time samples.

    32 is the time (milliseconds) per game frame.

    65535 is the maximum value of an unsigned short and corresponds to a full 360 degree rotation in the X-wing engine.

    OBSERVED ROTATION TIMES (REAL-TIME)
    Seconds to complete a full axis rotation.

    PITCH (AxisMult = 0.1)
    X-W: 5.216 seconds
    Y-W: 6.016
    A-W: 4.880
    B-W: 5.600

    ROLLING YAW (AxisMult = 0.04, include RollMult!)
    X-W: 3.138 seconds
    Y-W: 4.932
    A-W: 2.876
    B-W: 3.836

    ROLL (AxisMult = 0.08)
    X-W: 2.219 seconds
    Y-W: 3.483
    A-W: 2.031
    B-W: 2.709

    YAW (pure yaw, rolling disabled via hack) (AxisMult = 0.04)
    X-W: 4.416 seconds
    Y-W: 6.978
    A-W: 4.064
    B-W: 5.429

    Note that a rolling yaw is faster than a straight yaw. The change in roll appears to mirror the change in yaw, as a full rotation of a rolling yaw will leave the player in the same location, with the same craft orientation.

    Example: How to calculate the A-wing values, taking RealTimeMult into account. A-wing pitch is 4608, capped to 4096. Yaw is 15360, capped to 12288.

    Pitch = (65535 / (4096 * 0.1 * 1.0484775)) * 32 = 4883 ms
    Yaw = (65535 / (12288 * 0.04 * 1.4142 * 1.0484775)) * 32 = 2877 ms
    Roll = (65535 / (12288 * 0.08 * 1.0484775)) * 32 = 2034 ms

    Those values are within 3 ms of the observed averages. Observations were determined by collecting dozens of samples by programmatically examining game memory in real-time.

  5. Log in to comment