Home Game Development arithmetic – Rotate ‘left’ from the attitude of the house ship

### arithmetic – Rotate ‘left’ from the attitude of the house ship

I’m caught on the next math drawback for my recreation undertaking. I’ve an area ship which place and orientation is saved within the following class:

(The examples are in C# utilizing varieties from the System.Numberics namespace)

``````class Transform
{
Quaternion Rotation;
Vector3 Position;
}
``````

If I need to transfer the house ship ahead, as seen from the reference body (perspective) of the house ship I can do the next

``````remodel.Position += Vector3.Transform(new Vector3(0, 0, -1), Rotation);
``````

If I need to flip my house ship left (yaw 90 levels counter clockwise). I might do:

``````var relativeUp = Vector3.Transform(new Vector3(0, 1, 0), Rotation);
var rotation = Quaternion.CreateFromAxisAngle(relativeUp, PI / 2);
remodel.Rotation = rotation * remodel.Rotation;
``````

But I need to write this technique:

``````void RotateInReferenceFrame(Quaternion q);
``````

Where the enter quaternion `q` is constructed as `Quaternion.CreateFromYawPitchRoll((PI/2, 0, 0)` (so unaware of the present orientation of the house ship) however the ensuing rotation is finished within the reference body of the house ship (so the consequence is identical as the two step instance above).

Is this attainable?