Exemplo n.º 1
0
 def __init__(self, p, k, wavelength=550):
     super(Ray, self).__init__()
     self.k_history = []
     self.vertices = isVector(p).reshape((1, 3))
     self.k = isVector(k)
     self.wavelength = wavelength
     self.isTerminated = False
     self._n = air(
         self.wavelength)  # Index of refraction of the medium currently in
Exemplo n.º 2
0
    def __init__(self, center, direction, wavelength, polar=False):
        super(SingleRay, self).__init__(center)
        if polar:
            self.direction = asCartesian(direction)
        self.direction = isVector(self.direction)
        self.wavelength = wavelength

        self.ray_list = self._initRays()
 def __rmatmul__(self, other):
     T = type(other)
     if T is RationalVector:
         out = _matmul(other.value, self.value)
         outRa = RationalVector(out)
     elif T is RationalMatrix:
         out = _matmul(other.value, self.value)
         outRa = RationalMatrix(out)
     else:
         out = _matmul(other, self.value)
         if _utils.isSquare(out):
             outRa = RationalMatrix(out)
         elif _utils.isVector(out):
             outRa = RationalVector(out)
     return outRa
 def __add__(self, other):
     T = type(other)
     if T is int or T is _Fraction:
         out = self.value + other
         outRa = RationalVector(out)
     elif T is float:
         out = self.value + _Fraction(other)
         outRa = RationalVector(out)
     else:
         if T is RationalVector:
             out = self.value + other.value
         else:
             out = self.value + other
         if _utils.isVector(out):
             outRa = RationalVector(out)
         elif _utils.isSquare(out):
             outRa = RationalMatrix(out)
         else:
             raise ValueError('Dimension mismatch.')
     return outRa
Exemplo n.º 5
0
 def append(self, p, k):
     """Update the position and direction of the ray"""
     self.vertices = np.vstack((self.vertices, isVector(p)))
     self.k = isVector(k)