Exemple #1
0
 def __init__(self, x1, y1, x2, y2):
     '''
     @param x1: The first position of the boundary (x axis)
     @param y1: The first position of the boundary (y axis)
     @param x2: The second position of the boundary (x axis)
     @param y2: The second position of the boundary (y axis)
     '''
     super(Boundary, self).__init__(2)
     self.pos = numpy.array([x1, y1])
     self.vec = numpy.array([x2, y2]) - self.pos
 def __init__(self, x1, y1, x2, y2):
     '''
     @param x1: The first position of the boundary (x axis)
     @param y1: The first position of the boundary (y axis)
     @param x2: The second position of the boundary (x axis)
     @param y2: The second position of the boundary (y axis)
     '''
     super(Boundary, self).__init__(2)
     self.pos = numpy.array([x1, y1])
     self.vec = numpy.array([x2, y2]) - self.pos
 def __init__(self, x1, y1, z1, x2, y2, z2, x3, y3, z3):
     '''
     @param x1: The first position of the boundary (x axis)
     @param y1: The first position of the boundary (y axis)
     @param x2: The second position of the boundary (x axis)
     @param y2: The second position of the boundary (y axis)
     '''
     super(Boundary, self).__init__(3)
     self.pos = numpy.array([x1, y1, z1])
     self.vec1 = numpy.array([x2, y2, z2]) - self.pos
     self.vec2 = numpy.array([x3, y3, z3]) - self.pos
     
     if self.area() == 0:
         raise ValueError("Error: specified triangle has zero area. Either all three points are the same or all three lie on the same line")
Exemple #4
0
    def __init__(self, x1, y1, z1, x2, y2, z2, x3, y3, z3):
        '''
        @param x1: The first position of the boundary (x axis)
        @param y1: The first position of the boundary (y axis)
        @param x2: The second position of the boundary (x axis)
        @param y2: The second position of the boundary (y axis)
        '''
        super(Boundary, self).__init__(3)
        self.pos = numpy.array([x1, y1, z1])
        self.vec1 = numpy.array([x2, y2, z2]) - self.pos
        self.vec2 = numpy.array([x3, y3, z3]) - self.pos

        if self.area() == 0:
            raise ValueError(
                "Error: specified triangle has zero area. Either all three points are the same or all three lie on the same line"
            )
Exemple #5
0
 def get(self, idx):
     '''
     Returns the ith vertex
     '''
     return numpy.array([self.vertex1(), self.vertex2()])[idx]
Exemple #6
0
 def norm(self):
     '''
     return a unit vector in the direction of the norm.
     '''
     v = numpy.array([-self.vec[1], self.vec[0]])
     return v / numpy.linalg.norm(v)
 def norm(self):
     '''
     return a unit vector in the direction of the norm.
     '''
     v = numpy.array([-self.vec[1], self.vec[0]])
     return v / numpy.linalg.norm(v) 
 def get(self, idx):
     '''
     Returns the ith vertex
     '''
     return numpy.array([self.vertex1(), self.vertex2()])[idx]