Exemple #1
0
    def get_circumscribed_ellipsoid(self):
        """
        Return a circumscribed ellipsoid of the cylinder.
        """
        semiaxes = np.array(3 * [np.sqrt(2.0) * self.radius], dtype=np.float64)
        semiaxes[2] *= self.length_to_width
        mtx = np.diag(1.0 / (semiaxes**2))

        return mtx
Exemple #2
0
    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
Exemple #3
0
 def get_origin_bounding_box(self):
     """
     Get the ellipsoid's axes-aligned bounding box as if centered at the
     origin.
     
     Return:
         bbox : 3 x 2 array
             The bounding box.
     """
     aux = np.sqrt(np.diag(inv(self.mtx)))[:, np.newaxis]
     return np.c_[-aux, aux]
Exemple #4
0
 def get_origin_bounding_box(self):
     """
     Get the ellipsoid's axes-aligned bounding box as if centered at the
     origin.
     
     Return:
         bbox : 3 x 2 array
             The bounding box.
     """
     aux = np.sqrt(np.diag(inv(self.mtx)))[:,np.newaxis]
     return np.c_[-aux, aux]
Exemple #5
0
    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
Exemple #6
0
 def get_radius(self):
     r = np.sqrt((0.5 * self.height)**2 + self.radius**2)
     return r