DMGregory already explained how Quaternions are often used for rotation in 3d space. But Quaternions are already 2 levels of understand above imaginary numbers.
When you want to go one level simpler, then you might find it interesting that you can use Complex numbers for rotation in 2d space.
When you want to rotate a set of 2d points by n degrees, then you need to use this algorithm:
xnew = xold * cos(angle) - yold * sin(angle) ynew = yold * cos(angle) + xold * sin(angle) But a rotation by n degrees can actually be encoded as a complex number. When you treat the coordinates as complex numbers too, then you can do a rotation by simply multiplying the point by the rotation.
rotation.real = cos(angle) rotation.imaginary = sin(angle) newPoint = oldPoint * rotation You can also use complex numbers for scaling:
scale.real = xscale scale.imaginary = yscale newPoint = oldPoint * scale and as you might notice, scaling and rotation are both multiplication, so if you want to do both in the same step, you can encode both operations in one complex number by multiplying them:
rotation.real = cos(angle) rotation.imaginary = sin(angle) scale.real = xscale scale.imaginary = yscale rotationandscale = rotation * scale newPoint = oldPoint * rotationandscale