def compute_global_coords(self, glo=1): """ Return global surface coordinates (rot, t) wrt surface glo. """ tfrms = [] r, t = np.identity(3), np.array([0., 0., 0.]) prev = r, t tfrms.append(prev) # print(glo, t, *np.rad2deg(t3d.euler.mat2euler(r))) if glo > 0: # iterate in reverse over the segments before the # global reference surface go = glo path = itertools.zip_longest(self.ifcs[glo::-1], self.gaps[glo-1::-1]) after = next(path) # loop of remaining surfaces in path while True: try: before = next(path) go -= 1 zdist = after[Gap].thi r, t = trns.reverse_transform(before[Intfc], zdist, after[Intfc]) t = prev[0].dot(t) + prev[1] r = prev[0].dot(r) # print(go, t, # *np.rad2deg(euler2opt(t3d.euler.mat2euler(r)))) prev = r, t tfrms.append(prev) after = before except StopIteration: break tfrms.reverse() path = itertools.zip_longest(self.ifcs[glo:], self.gaps[glo:]) before = next(path) prev = np.identity(3), np.array([0., 0., 0.]) go = glo # loop forward over the remaining surfaces in path while True: try: after = next(path) go += 1 zdist = before[Gap].thi r, t = trns.forward_transform(before[Intfc], zdist, after[Intfc]) t = prev[0].dot(t) + prev[1] r = prev[0].dot(r) # print(go, t, # *np.rad2deg(euler2opt(t3d.euler.mat2euler(r)))) prev = r, t tfrms.append(prev) before = after except StopIteration: break return tfrms
def setup_shift_of_ray_bundle(seq_model, start_offset): """ compute transformation for rays "start_offset" from 1st surface Args: seq_model: the sequential model start_offset: z distance rays should start wrt first surface. positive if to left of first surface Returns: transformation rotation and translation:: (rot, t) """ s1 = seq_model.ifcs[1] s0 = seq_model.ifcs[0] rot, t = transform.reverse_transform(s0, start_offset, s1) return rot, t
def compute_global_coords(self, glo=1): """ Return global surface coordinates (rot, t) wrt surface glo. """ tfrms = [] r, t = np.identity(3), np.array([0., 0., 0.]) prev = r, t tfrms.append(prev) if glo > 0: # iterate in reverse over the segments before the # global reference surface step = -1 seq = itertools.zip_longest(self.ifcs[glo::step], self.gaps[glo - 1::step]) ifc, gap = after = next(seq) # loop of remaining surfaces in path while True: try: b4_ifc, b4_gap = before = next(seq) zdist = gap.thi r, t = trns.reverse_transform(ifc, zdist, b4_ifc) t = prev[0].dot(t) + prev[1] r = prev[0].dot(r) prev = r, t tfrms.append(prev) after, ifc, gap = before, b4_ifc, b4_gap except StopIteration: break tfrms.reverse() seq = itertools.zip_longest(self.ifcs[glo:], self.gaps[glo:]) b4_ifc, b4_gap = before = next(seq) prev = np.identity(3), np.array([0., 0., 0.]) # loop forward over the remaining surfaces in path while True: try: ifc, gap = after = next(seq) zdist = b4_gap.thi r, t = trns.forward_transform(b4_ifc, zdist, ifc) t = prev[0].dot(t) + prev[1] r = prev[0].dot(r) prev = r, t tfrms.append(prev) before, b4_ifc, b4_gap = after, ifc, gap except StopIteration: break return tfrms