Page MenuHomeFeedback Tracker

Engine Rotation Issues - Loss of Axis Rotation in Local Space
New, NormalPublic

Description

When a point is rotated more than 90 degrees on two axes in local space, one of the axes is lost. This issue is difficult to understand without examples, so here are some.

With SetOrientation()

// offset is vector in angles
armorPiece.SetOrientation(offset + "0 90 90");

This should logically rotate the object with an offset of +90 degrees on both the Y and Z axes.
Tests with different offsets:
offset = "0 0 0"


offset = "90 0 0"

offset = "0 90 0"

offset = "0 0 90"

As you can see, the X axis is completely lost.

Manual rotation of a point in space
Sorry for the complex example:

float radAngle = Math.DEG2RAD * ConeAngle;

float theta = Math.RandomFloatInclusive(0, radAngle);
float phi = Math.RandomFloatInclusive(0, Math.PI2);

float x = Math.Sin(theta) * Math.Cos(phi);
float y = Math.Sin(theta) * Math.Sin(phi);
float z = Math.Cos(theta);

vector localDir = Vector(x, y, z);

This creates a direction vector in local space, randomly positioned within a cone of angle ConeAngle.
Now, I want to rotate this vector twice using directional vectors.

// ConeVector is directional vector I want to align my vector with
vector transform[3];
Math3D.DirectionAndUpMatrix(ConeVector, vector.Up, transform);
localDir = localDir.Multiply3(transform);

If I apply this transformation once, it works as expected:
ConeVector:
"0 1 0"


"0 -1 0"

"1 0 0"

"-1 0 0"

However, when I apply the same rotation again, an axis is lost:
"0 1 0"


"0 -1 0"

"1 0 0"

"-1 0 0"

Both X and Y rotate on one axis but in different directions.

InventorySlotsOffsets Issue
This issue is easiest to replicate using InventorySlotsOffsets.
Here, I add the InventorySlotsOffsets for the Belt_Right slot to the holster:
"0 90 90"


"90 90 90"

"0 180 90"

"0 90 180"

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 11 x64
Operating System Version
10.0.26100
Category
Engine
Steps To Reproduce

Easiest one is with InventorySlotsOffsets just rotate more than 90 in two axes, then add another another rotation in all axes to see the difference.
Or with SetOrientation(offset + "0 90 90")

Additional Information

I'm no mathematician, so I can't say why this happens, but it's not an issue with the method, I tried different approaches, and the result was always the same.
If other modders have examples of this behaviour please share them.

Event Timeline

Genriet1 created this task.Sat, Mar 15, 3:30 PM