# Simplify Matrix math code- Sun billboarding

If was trying to set the correct position of my sun billboard in my 3d game. I tried long until it worked correctly, but I wonder why this code must be so complicated:

sun.sprite.Position = Vector3.Transform(Vector3.Transform(-sun.lightDir,
Quaternion.Inverse(world.Rotation)), Quaternion.Inverse(myRelativeRotation));


Can I simplify this expression? I tried changing it at least to this:

sun.sprite.Position = Vector3.Transform(-sun.lightDir,
Quaternion.Inverse(world.Rotation) * Quaternion.Inverse(myRelativeRotation))


But this is giving me different results, so the sun is at the wrong position.

• Have you tried reversing the order of multiplication of the quaternions in your second example? – DMGregory Feb 22 '19 at 22:37

sun.sprite.Position = Vector3.Transform(-sun.lightDir,

A^-1 * B^-1 = (B * A)^-1