Transform orientation.to_euler() in an interval beetween 0 and 2*pi

Hi! I’m wondering how we could convert object.orientation.to_euler().x in an interval beetween 0 and 2*pi… Is there a function for that in the API? Or is there a math formula to do that? Thanks!

EDIT: finally I made that:

ori = own.orientation.to_euler().x

if ori < 0:
    ori += 2*pi

ori = cos(ori)+1

This make ori clamped beetween 0 and 2 and this is perfect for my needs

Or, use the modulo operator


angle = own.world_orientation.to_euler().x % (2 * pi)

NB. Don’t use “orientation”, it’s deprecated, because get/set is different. Use world/local orientations.

Hi! Ah yes, you’re right. It’s been 2 or 3 weeks that I use % to make such things (come back to the beginning of a list…) but I didn’t think about that this time (maybe because negative numbers get myself confused). Thanks for the tip.

NB. Don’t use “orientation”, it’s deprecated, because get/set is different. Use world/local orientations.

world_orientation too :stuck_out_tongue: Yes. I’ll use worldOrientation or localOrientation next time :slight_smile: