Lets say we have this Part:

Where the Red cross marks the Front of the part and the blue one the Top.
In this Position&Rotation i would want to get the Number 0.
But in this state:

i would like to get the number 45 returned.
And now my problem:


I would also still like to get the number 45 returned no matter how much this Part is pitched up and down. I just want to get Rotation on its Local Z axis.
Another Example:

This should return 90.
I cant figure it out how to get those when the part is pitched.
Can someone pls help me…
Thanks!