Thursday, August 11, 2022
HomeGame Developmentarithmetic - Rotate 'left' from the attitude of the area ship

arithmetic – Rotate ‘left’ from the attitude of the area ship


I am caught on the next math downside for my recreation venture. 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 Remodel
{
  Quaternion Rotation;
  Vector3 Place;
}

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

rework.Place += Vector3.Remodel(new Vector3(0, 0, -1), Rotation);

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

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

However I need to write this technique:

void RotateInReferenceFrame(Quaternion q);

The place the enter quaternion q is constructed as Quaternion.CreateFromYawPitchRoll((PI/2, 0, 0) (so unaware of the present orientation of the area ship) however the ensuing rotation is completed within the reference body of the area ship (so the outcome is similar as the two step instance above).

Is that this attainable?

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments