I think in this particular case you should be able to actually use the coordinate system in the STL for that. most things for printing you'll likely want to see how it would be coming out of the printer so you'll have an actual up direction defined before you do this. Should save a lot of computation there.