@batFinger: thanks again, i did try this in blender and not only for XYZ.
From what you have the opinion the representation of angles used in this game-model is euler-XYZ?
If you dont know what kind - how to find it out? Can you “see” it from my working back-calculations what it is?
I even tried such a brute force to check what it might be:
#!/usr/local/bin/python3.2
#
import math
# axis sequences for Euler angles
_NEXT_AXIS = [1, 2, 0, 1]
# map axes strings to/from tuples of inner axis, parity, repetition, frame
_AXES2TUPLE = {
'sxyz': (0, 0, 0, 0), 'sxyx': (0, 0, 1, 0), 'sxzy': (0, 1, 0, 0),
'sxzx': (0, 1, 1, 0), 'syzx': (1, 0, 0, 0), 'syzy': (1, 0, 1, 0),
'syxz': (1, 1, 0, 0), 'syxy': (1, 1, 1, 0), 'szxy': (2, 0, 0, 0),
'szxz': (2, 0, 1, 0), 'szyx': (2, 1, 0, 0), 'szyz': (2, 1, 1, 0),
'rzyx': (0, 0, 0, 1), 'rxyx': (0, 0, 1, 1), 'ryzx': (0, 1, 0, 1),
'rxzx': (0, 1, 1, 1), 'rxzy': (1, 0, 0, 1), 'ryzy': (1, 0, 1, 1),
'rzxy': (1, 1, 0, 1), 'ryxy': (1, 1, 1, 1), 'ryxz': (2, 0, 0, 1),
'rzxz': (2, 0, 1, 1), 'rxyz': (2, 1, 0, 1), 'rzyz': (2, 1, 1, 1)}
_TUPLE2AXES = dict((v, k) for k, v in _AXES2TUPLE.items())
_EPS = 0.000000001
def euler_from_matrix(matrix, axes='sxyz'):
"""Return Euler angles from rotation matrix for specified axis sequence.
axes : One of 24 axis sequences as string or encoded tuple
Note that many Euler angle triplets can describe one matrix.
>>> R0 = euler_matrix(1, 2, 3, 'syxz')
>>> al, be, ga = euler_from_matrix(R0, 'syxz')
>>> R1 = euler_matrix(al, be, ga, 'syxz')
>>> numpy.allclose(R0, R1)
True
>>> angles = (4*math.pi) * (numpy.random.random(3) - 0.5)
>>> for axes in _AXES2TUPLE.keys():
... R0 = euler_matrix(axes=axes, *angles)
... R1 = euler_matrix(axes=axes, *euler_from_matrix(R0, axes))
... if not numpy.allclose(R0, R1): print(axes, "failed")
"""
try:
firstaxis, parity, repetition, frame = _AXES2TUPLE[axes.lower()]
except (AttributeError, KeyError):
_TUPLE2AXES[axes] # validation
firstaxis, parity, repetition, frame = axes
i = firstaxis
j = _NEXT_AXIS[i+parity]
k = _NEXT_AXIS[i-parity+1]
M = matrix #[[0,0,0],[0,0,0],[0,0,0]] #numpy.array(matrix, dtype=numpy.float64, copy=False)[:3, :3]
if repetition:
sy = math.sqrt(M[i][j]*M[i][j] + M[i][k]*M[i][k])
# print("sy:", sy)
if sy > _EPS:
ax = math.atan2( M[i][j], M[i][k])
ay = math.atan2( sy, M[i][i])
az = math.atan2( M[j][i], -M[k][i])
else:
ax = math.atan2(-M[j][k], M[j][j])
ay = math.atan2( sy, M[i][i])
az = 0.0
else:
cy = math.sqrt(M[i][i]*M[i][i] + M[j][i]*M[j][i])
# print("cy:", cy)
if cy > _EPS:
ax = math.atan2( M[k][j], M[k][k])
ay = math.atan2(-M[k][i], cy)
az = math.atan2( M[j][i], M[i][i])
else:
ax = math.atan2(-M[j][k], M[j][j])
ay = math.atan2(-M[k][i], cy)
az = 0.0
if parity:
ax, ay, az = -ax, -ay, -az
if frame:
ax, az = az, ax
return ax, ay, az
mat = [[ 0.8780784606933594, -0.20382282137870789, -0.43293705582618713],
[0.13696907460689545, 0.9739492535591125, -0.18072718381881714],
[0.45849505066871643, 0.09939365088939667, 0.8831212520599365]
]
print(mat)
euler = euler_from_matrix(mat, "sxyz")
print(euler)
for angles in [ [0,0,0], [0,90,0], [90,0,0], [90,0,90], [45,45,45], [30,10,-120], [90,180,45] ]:
# angles = [0,90,0]
mat = [ [0,0,0], [0,0,0], [0,0,0] ]
AngleVectors(angles, mat[0], mat[1], mat[2])
print("test:", angles)
reverseAngleVectors(angles, mat[0], mat[1], mat[2])
print("rev.:", angles)
if False:
# for i in range(3):
# mat[1][i] *= -1
# print(mat)
mat2 = [ [ mat[0][0], mat[1][0], mat[2][0] ], [ mat[0][1], mat[1][1], mat[2][1] ], [ mat[0][2], mat[1][2], mat[2][2] ] ]
for axstr in _AXES2TUPLE.keys():
#print(axstr)
angles = [ degrees(f) for f in euler_from_matrix( mat, axes=axstr) ]
print(axstr, angles)
i have to give credit to the one for this python-matrix-to-euler routine … but i dont find the link the quick way …
i think this: http://www.lfd.uci.edu/~gohlke
(hell and again some char-conversion … might be a “tilde”)
edit found link: http://www.lfd.uci.edu/~gohlke/code/transformations.py.html