Buongiorno non riesco a capire l'errore che mi restituisce sul seguente codice:
File "C:\Users\loris\Desktop\MY_WRK_SPACE\RBTEST\eul_rot_zyx.py", line 27
if abs(R.item(0,0)) < tol and abs(R.item(1,0)) < tol:
IndentationError: unexpected indent
linea rossa sotto l'istruzione IF. Come posso risolvere . Non riesco. Grazie
import numpy as np
import math as m
import sys
def Rx(theta):
return np.matrix([[1, 0, 0],
[0, m.cos(theta), -m.sin(theta)],
[0, m.sin(theta), m.cos(theta)]])
def Ry(theta):
return np.matrix([[m.cos(theta), 0, m.sin(theta)],
[0, 1, 0],
[-m.sin(theta), 0, m.cos(theta)]])
def Rz(theta):
return np.matrix([[m.cos(theta), -m.sin(theta), 0],
[m.sin(theta), m.cos(theta), 0],
[0, 0, 1]])
phi = m.pi/2
theta = m.pi/4
psi = m.pi/2
eul1=0
R = Rz(psi) * Ry(theta) * Rx(phi)
tol = sys.float_info.epsilon * 10
if abs(R.item(0,0)) < tol and abs(R.item(1,0)) < tol: //LINEA 27 ERRATA
eul1 = 0
eul2 = m.atan2(-R.item(2, 0), R.item(0, 0))
eul3 = m.atan2(-R.item(1, 2), R.item(1, 1))
else:
eul1 = m.atan2(R.item(1, 0), R.item(0, 0))
sp = m.sin(eul1)
cp = m.cos(eul1)
eul2 = m.atan2(-R.item(2, 0), cp*R.item(0, 0)+sp*R.item(1, 0))
eul3 = m.atan2(sp*R.item(0, 2)-cp*R.item(1, 2), cp*R.item(1, 1)-sp*R.item(0, 1))
print("phi =", eul1)
print("theta =", eul2)
print("psi =", eul3)