def can_drop(p0, p1, p2): if p2[2] - p0[2] > 15: return False if geo.dist_meters(p0, p2, geo.NEW_YORK) > 25: return False if geo.dist_meters(p0, p1, geo.NEW_YORK) < 10 or \ geo.dist_meters(p1, p2, geo.NEW_YORK) < 10: return True if geo.angle(p0, p1, p2, geo.NEW_YORK) > 15: return False return True
def rotate_lipid(lipid) : lipidmasses = lipid.collect("masses") xyz = lipid.collect("xyz") center = xyz.mean(axis=0) xyz = xyz - center moi = geo.momentOfInertia(xyz,lipidmasses) princip = geo.principalAxes(moi) normv = np.array([0.0,0.0,1.0]) rotvec = geo.rotaxis(princip[0,:],normv) alpha = geo.angle(princip[0,:],normv) rotmat = geo.rotation_matrix(alpha,rotvec) lipid.update_xyz(fitting.rotate(xyz,rotmat)+center)
def parse(self, data, para): """ :param data: Observed data :param para: :return: x, y, z, c """ ang = angle(data['heading']) height = para['height_coeff']/math.sqrt(math.fabs(data['size'])) x = data['center'][0]/para['img_w']*2-1 x *= para['x_coeff']*height y = data['center'][1]/para['img_h']*2-1 y *= para['y_coeff']*height # height = data['size'] return x, y, height, ang
def update(self, state): out_c = self.c_pid.update(state.c) out_xy = self.xy_pid.update(math.sqrt(state.x*state.x+state.y*state.y)) out_z = self.z_pid.update(state.z) theta = angle((state.x, state.y)) - state.c return out_xy*math.cos(theta), out_xy*math.sin(theta), out_z, 0, 0, out_c