Rotation of a 3d angle.

Hi folks. I’m sure this answer is out there a hundred times, but I’m struggling to find anything that makes sense. I’m pretty sure this is because I’m a bit thick!

I’m trying to create a 3D, non friction steering system. I have an object moving between arbitrary points without any problem, but I’m struggling to add steering.

In a 2D project I just hold a steering value as a single of radians, and I add or reduce this value by a thrust force, Turn this into a vector and multiply it into my Velocity.

This is exactly what I wan’t to do in the 3D environment, but now I need a steering 3D vector, which I need to rotate. That’s where I’m stuck.

Is there a magic way to achieve this, (rotate 3D vector towards xyz by rr radians), do I need to do this as a manual process, or should I be using a Matrix translation?

I guess if I start with a vector of 0,1,0 and CreateRotation(xx,yy,zz) that’s what I’m looking for? Is the resulting vector the same length?

Brain at boiling point!!

Any help with this would be great.

Many thanks.

You can use Quaternions and axis angle
or.
You can use Matrix AxisAngle and your world Matrix’s Up and Right normal vector to create a rotation matrix that you can multiply against your current World Orientation matrix to stear it left or right from the current forward look at vector.
That is for free turning look at camera.

You can alternately instead use system vectors to perform system coordinate turns.
Just using create rotation and multiplying it by your world matrix.

In that case you might as well just use Quaternions for the rotations Quaternions can make things simpler or harder depending on the use case.

In the case you want to use matrices and make a fully free camera.

Think of it with your fore finger index and thumb orient each finger 90 degrees to the other point them in front of you this is the system orientation it is unchanging your thumb is up your index is left or right ect.

Then move your wrist this is your world orientation it has up your thumb and left althogh these are no longer equal to the system vectors you never the less have them in your world matrix as vectors and can use them for axis angle rotations to create a up or down axis angle rotation to reapply to that same world orientation matrix.

To say imagine with your fingers at 90 degrees and your wrist in some arbitrary pointed direction take your other hand grab your thumb and twist your hand that is a AxisAngle Rotation about the up thumb vector of your abritrarily pointing local matrix the amount of radians you rotate the Axis angle can be positive or negative which equates no matter were your camera is oriented in your world to either turning were you are looking at right a positive amount of radians or turning the direction you are looking at to the left a negative amount of radians.

Conversely your index finger represents looking up or down and a axis angle rotation on your forefinger is a roll clockwise or counterclockwise multiply any of these resulting matrix rotations to the original rotation matrix performs a directional change.

Alternerately you can also perform a axis angle rotation and then use that in concert with create world to form a new matrix.

If you scroll down a bit you will see a ton of operations all the possible system and local rotational operations are listed for matrices.

Matrix.CreateRotation|X, Y, or Z| will definitely do what you think it will, and keeps the vector length.