你好,以下是一段代码,请帮我解释一下为什么 elevation, azimuth = self.getT(tgtw2c, condw2c) 计算后的结果是弧度制,而不是角度?…
- User
你好,以下是一段代码,请帮我解释一下为什么 elevation, azimuth = self.get_T(tgt_w2c, cond_w2c) 计算后的结果是弧度制,而不是角度?
def get_T(self, target_RT, cond_RT): R, T = target_RT[:3, :3], target_RT[:, -1] T_target = -R.T @ T # change to cam2worldcodeR, T = cond_RT[:3, :3], cond_RT[:, -1] T_cond = -R.T @ T theta_cond, azimuth_cond, z_cond = self.cartesian_to_spherical(T_cond[None, :]) theta_target, azimuth_target, z_target = self.cartesian_to_spherical(T_target[None, :]) d_theta = theta_target - theta_cond d_azimuth = (azimuth_target - azimuth_cond) % (2 * math.pi) d_z = z_target - z_cond # d_T = torch.tensor([d_theta.item(), math.sin(d_azimuth.item()), math.cos(d_azimuth.item()), d_z.item()]) return d_theta, d_azimuth def cartesian_to_spherical(self, xyz): ptsnew = np.hstack((xyz, np.zeros(xyz.shape))) xy = xyz[:,0]**2 + xyz[:,1]**2 z = np.sqrt(xy + xyz[:,2]**2) theta = np.arctan2(np.sqrt(xy), xyz[:,2]) # for elevation angle defined from Z-axis down #ptsnew[:,4] = np.arctan2(xyz[:,2], np.sqrt(xy)) # for elevation angle defined from XY-plane up azimuth = np.arctan2(xyz[:,1], xyz[:,0]) return np.array([theta, azimuth, z])conditional RT front view 1.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 0.000000000000000000e+00 -1.343588564850506373e-07 1.000000119209289551e+00 -1.343588564850506373e-07 0.000000000000000000e+00 -1.000000119209289551e+00 -1.343588564850506373e-07 -1.000000119209289551e+00 target RT left view
- Assistant