Seemingly crazy (?) maths problem. Help wanted pls

wow that’s some math! I don’t understand it though. Sorry.

Would it be easy to use quaternions? I painstakingly when through installing this Blueprint library to expose quat functions to blueprints but don’t know if they’re of any use to me