Exemplo n.º 1
0
    def __init__(self, length=[], transform=[], fixed_points=[], sc = True):
        """ellipsoid(length: float list, transform:(string, transformation_data) list,
        fixed_points: float list list , sc:bool).
        
        Creates an ellipsoid given the length of
        the main axes. The ellipsoid is transformed following the order
        of the transformations specified in the transform list.
        Calling ai (i = 1,2,...) the axis of the space where the object is
        defined, examples of these transformations are:
        - ("shift", [a1,a2,a3,..]) 
        - ("scale", [a1,a2,a3,...])
        - ("rotate", [a1,a2], phi)
        - ("rotate2d", phi)
        - ("rotate3d", [a1,a2,a3], phi)
        If sc = False the transformations are made wrt the body coordinates,
        wrt the system coordinates otherwise.
        """

        dim = len(length) 
        mesh_obj.__init__(self,dim, fixed_points)
        
        print "ellips"
        self.obj = ocaml.body_ellipsoid(length)

        self.transformations(transform,sc)
Exemplo n.º 2
0
    def __init__(self,length=[],shifting=[], outer_box = [], sc = True):
        """ellipsoid(length: float list, shifting: float list,
        outer_box:[float list, float list], sc:bool).
        Creates an ellipsoid given the length of
        the main axes. The ellipsoid is shifted to the position shifting
        wrt the origin of coordinates system. If sc = False, the shift
        is wrt the centre of the ellipsoid
        """
        mesh_obj.__init__(self)

        if length == [] and shifting != []:          # only shifting is given
            for i in range(len(shifting)):
                length.append(1.0)
                
        elif length != [] and shifting == []:        # only length is given
            for i in range(len(length)):
                shifting.append(0.0)
        elif length == [] and shifting == []:        # default: 2D
            for i in range(2):
                length.append(1.0)
                shifting.append(0.0)
        else:
            pass

        print "ellips"
        print length , shifting
        if sc:                                       # system coordinates
            self.obj.append(ocaml.body_shifted_sc(ocaml.body_ellipsoid(length),shifting))
        else:                                        # body coordinates
            self.obj.append(ocaml.body_shifted_bc(ocaml.body_ellipsoid(length),shifting))


        min_coords = []                              # create bounding box
        max_coords = []

        for i in range(len(shifting)):
            if outer_box == []:
                min_coords.append(-length[i]+shifting[i])
                max_coords.append(length[i]+shifting[i])
            else:
                min_coords.append(min(-length[i]+shifting[i], outer_box[0][i], outer_box[1][i]))
                max_coords.append(max(length[i]+shifting[i],outer_box[0][i], outer_box[1][i]))

        self.bbox = [min_coords, max_coords]          # update bounding box   
        print "bbox"
        print self.bbox
        print "ellips.\n"