示例#1
0
 def __new__(cls, radius=1, center=[0,0,0], direction=[0,0,1], closed=False, **kwargs):
     """
     >>> from sympy import *
     >>> from symplus.strplus import init_mprinting
     >>> init_mprinting()
     >>> InfiniteCylinder()
     InfiniteCylinder(1, [0 0 0]', [0 0 1]', False)
     >>> InfiniteCylinder(2, [0,0,0], [0,1,1])
     InfiniteCylinder(2, [0 0 0]', [0 -sqrt(2)/2 -sqrt(2)/2]', False)
     >>> InfiniteCylinder().contains((1,1,1))
     False
     >>> InfiniteCylinder(2, [0,0,0], [0,1,1]).contains((1,1,1))
     True
     """
     normalization = kwargs.pop("normalization", True)
     radius = sympify(abs(radius))
     direction = Mat(direction)
     if normalization:
         if norm(direction) == 0:
             raise ValueError
         direction = simplify(normalize(direction))
     direction = max(direction, -direction, key=hash)
     center = Mat(center)
     if normalization:
         center = simplify(center - project(center, direction))
     closed = sympify(bool(closed))
     return Basic.__new__(cls, radius, center, direction, closed)
示例#2
0
 def _image(self, func):
     if isinstance(func, EuclideanTransformation):
         radius = self.radius
         direction = simplify(qrotate(func.rquat, func.parity*self.direction))
         center = simplify(qrotate(func.rquat, func.parity*self.center))
         center = simplify(center + func.tvec - project(func.tvec, direction))
         closed = self.closed
         return InfiniteCylinder(
             radius=radius,
             center=center,
             direction=direction,
             closed=closed,
             normalization=False)
示例#3
0
 def as_algebraic(self):
     center = simplify(self.center - project(self.center, self.direction))
     coffset = dot(self.center, self.direction)
     return Intersection(
         InfiniteCylinder(
             radius=self.radius,
             center=center,
             direction=self.direction,
             closed=self.closed,
             normalization=False),
         Halfspace(
             offset= coffset - self.height/sympify(2),
             direction= self.direction,
             closed=self.closed,
             normalization=False),
         Halfspace(
             offset=-coffset - self.height/sympify(2),
             direction=-self.direction,
             closed=self.closed,
             normalization=False))