# How to rotate a sphere on its axis with a tilt?

How can I simulate a planet's rotation on the Z axis but tilted x° ( similar to how the Earth's rotation axis is tilted 23° relative to its orbit).

I know with Euler angles I'll meet some gimbal lock issues, so I'm looking for a quaternion solution.

EDIT :

Ended up doing something like that in my update :

SpinAngle += deltaTime * Speed;
Quaternion rotationAboutAxis = Quaternion.Euler(0, SpinAngle, 0);
Quaternion tiltOfAxis = Quaternion.Euler(0, 0, TiltAngle);
transform.rotation = tiltOfAxis * rotationAboutAxis ;


Where TiltAngle is in degree :) Thanks !

You can just compose the quaternions.

// Rotate by spinAngle degrees about our local z+ axis.
var rotationAboutAxis = Quaternion.Euler(0, 0, spinAngle);

// Tilt the object's z+ spin axis by tiltAngle on the parent/world x+ axis.
var tiltOfAxis = Quaternion.Euler(tiltAngle, 0, 0);