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 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
def compute_local_transforms(self): """ Return forward surface coordinates (r.T, t) for each interface. """ tfrms = [] path = itertools.zip_longest(self.ifcs, self.gaps) before = next(path) while before is not None: try: after = next(path) except StopIteration: tfrms.append((np.identity(3), np.array([0., 0., 0.]))) break else: zdist = before[Gap].thi r, t = trns.forward_transform(before[Intfc], zdist, after[Intfc]) rt = r.transpose() tfrms.append((rt, t)) before = after return tfrms
def compute_local_transforms(self, seq=None, step=1): """ Return forward surface coordinates (r.T, t) for each interface. """ tfrms = [] if seq is None: seq = itertools.zip_longest(self.ifcs[::step], self.gaps[::step]) b4_ifc, b4_gap = before = next(seq) while before is not None: try: ifc, gap = after = next(seq) except StopIteration: tfrms.append((np.identity(3), np.array([0., 0., 0.]))) break else: zdist = step * b4_gap.thi r, t = trns.forward_transform(b4_ifc, zdist, ifc) rt = r.transpose() tfrms.append((rt, t)) before, b4_ifc, b4_gap = after, ifc, gap return tfrms