Rotation matrix way to complicated for little old me :P

In blender GE is there a way to get an object to report its current rotation in degrees instead of a rotation matrix. The object.postion function is exactly what I need only for rotation, like object.rotation and it would return (0.0, 0.0, 90.0). I can only assume that the object.orientation which returns a rotation matrix is useful to some people (those who have advanced degrees in calculus maybe) but for those of us who simply need to know how much something is rotated it’s a little bit overkill.

Don’t have Blender on this machine to test’er out but maybe give the following a try:


e = bpy.data.objects[0].matrix_world.to_euler('XYZ')
x = degrees(e[0])
y = degrees(e[1])
z = degrees(e[2])

:confused:

Thats close but it doesn’t work in real time. I tried it on an object that was rotating in game and it just kept returning the same values. Also it wasn’t in degrees but i should still be able to use it if I could get it to update.

Hello? Anyone?

try this ;

import bge
import math
from mathutils import *

c = bge.logic.getCurrentController()
co = c.owner

# Radians to Degrees
def rad2deg(rad):
    return (rad/math.pi)*180.0

#World
coRM = co.worldOrientation

Euler = coRM.to_euler()

X = rad2deg(Euler[0])
Y = rad2deg(Euler[1])
Z = rad2deg(Euler[2])

print( (X,Y,Z) )

…and it’s not calculus, it’s trigonometry & linear algebra :wink:

That was it exactly, thank you.

…and it’s not calculus, it’s trigonometry & linear algebra :wink:

Shows what I know :slight_smile:

with mathutl you already have a function for angles

radians () and angles ()

happy 2.5