def __contains__(self, point): """ Point x in cylinder. """ x = point - self.centre aux = np.dot(self.rot_mtx, x) r = np.sqrt(aux[0]**2 + aux[1]**2) val = (np.abs(aux[2]) <= self.height) & (r <= self.radius) return val
def contains(self, points): """ Point x in cylinder. Works for array of points. Parameters ---------- points : (n_point, 3) array The points to be tested for inclusion. """ points = np.array(points, ndmin=2, dtype=np.float64) x = points.T - self.centre[:,np.newaxis] aux = np.dot(self.rot_mtx, x) r = np.sqrt(aux[0,:]**2 + aux[1,:]**2) mask = (np.abs(aux[2,:]) <= (0.5 * self.height)) & (r <= self.radius) return mask