I was able to come up with a function to generate a 3x3 matrix from the vector you would plug into the older axis
option from 2.79’s transform.rotate
. You then enter the matrix this function returns into 2.80’s orient_matrix
option and set the orient_axis
equal to 'Z'
in the updated transform.rotate
syntax and it should work the same as it did in 2.79. My function below is based off of this function in Animation Nodes.
from math import isclose
from mathutils import Matrix, Vector
def create_z_orient(rot_vec):
x_dir_p = Vector(( 1.0, 0.0, 0.0))
y_dir_p = Vector(( 0.0, 1.0, 0.0))
z_dir_p = Vector(( 0.0, 0.0, 1.0))
tol = 0.001
rx, ry, rz = rot_vec
if isclose(rx, 0.0, abs_tol=tol) and isclose(ry, 0.0, abs_tol=tol):
if isclose(rz, 0.0, abs_tol=tol) or isclose(rz, 1.0, abs_tol=tol):
return Matrix((x_dir_p, y_dir_p, z_dir_p)) # 3x3 identity
new_z = rot_vec.copy() # rot_vec already normalized
new_y = new_z.cross(z_dir_p)
new_y_eq_0_0_0 = True
for v in new_y:
if not isclose(v, 0.0, abs_tol=tol):
new_y_eq_0_0_0 = False
break
if new_y_eq_0_0_0:
new_y = y_dir_p
new_x = new_y.cross(new_z)
new_x.normalize()
new_y.normalize()
return Matrix(((new_x.x, new_y.x, new_z.x),
(new_x.y, new_y.y, new_z.y),
(new_x.z, new_y.z, new_z.z)))