def carvedVolume(self): ''' Basic linalg, since we carve out volume from the origin. Then, let a = pos - O, b = vec1, c = vec2 Then V = (a * (b x c)) / 6 The first term is for the direction this volume is with respect to the origin. ''' return numpy.sign(numpy.dot(self.pos, self.norm())) \ * numpy.dot(self.pos, numpy.cross(self.vec1, self.vec2)) / 6.0
def norm(self): ''' Returns normal to this plane ''' v = numpy.cross(self.vec1, self.vec2) return v / numpy.linalg.norm(v)
def area(self): ''' returns the area of this boundary. I'm still not sure if this will have any use ''' return numpy.linalg.norm(numpy.cross(self.vec1, self.vec2)) / 2.0
def carvedVolume(self): # signum(N . pos) * ||pos x vec||/2 return numpy.sign(numpy.dot(self.pos, self.norm())) \ * numpy.linalg.norm(numpy.cross(self.pos, self.vec)) / 2