Not sure if you're seeking the method or just the answer, but I use this tool:
https://www.andre-gaschler.com/rotationconverter/
It's open source, so you could presumably figure out how it works.
https://www.andre-gaschler.com/rotationconverter/
It's open source, so you could presumably figure out how it works.