From 3a73f3a5ce9c1ac7a74af95e8a435733e68794e2 Mon Sep 17 00:00:00 2001 From: Chris Maffeo <cmaffeo2@illinois.edu> Date: Fri, 21 Dec 2018 12:10:10 -0600 Subject: [PATCH] Updated set_spline routine to include more detail --- mrdna/segmentmodel.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/mrdna/segmentmodel.py b/mrdna/segmentmodel.py index d4333ed..5a9f4c5 100644 --- a/mrdna/segmentmodel.py +++ b/mrdna/segmentmodel.py @@ -503,11 +503,11 @@ class Segment(ConnectableElement, Group): if about is None: ## TODO: do this more efficiently - r[ids,:] = np.array([rotation_matrix.dot(r[i,:]) for i in range(r.shape[0])]) + r[ids,:] = np.array([rotation_matrix.dot(r[i,:]) for i in ids]) else: dr = np.array(about) ## TODO: do this more efficiently - r[ids,:] = np.array([rotation_matrix.dot(r[i,:]-dr) + dr for i in range(r.shape[0])]) + r[ids,:] = np.array([rotation_matrix.dot(r[i,:]-dr) + dr for i in ids]) self.set_splines(u,r) @@ -520,10 +520,14 @@ class Segment(ConnectableElement, Group): quats = [quaternion_from_matrix(o) for o in orientations] self.set_orientation_splines(u, quats) - def _set_splines_from_ends(self): + def _set_splines_from_ends(self, resolution=4): self.quaternion_spline_params = None - coords = np.array([self.start_position, self.end_position]) - self.set_splines([0,1], coords) + r0 = np.array(self.start_position)[np.newaxis,:] + r1 = np.array(self.end_position)[np.newaxis,:] + u = np.linspace(0,1, max(3,self.num_nt//int(resolution))) + s = u[:,np.newaxis] + coords = (1-s)*r0 + s*r1 + self.set_splines(u, coords) def clear_all(self): Group.clear_all(self) # TODO: use super? @@ -1002,11 +1006,6 @@ class DoubleStrandedSegment(Segment): # for l in (self.start5,self.start3,self.end3,self.end5): # self.locations.append(l) - ## Set up interpolation for azimuthal angles - a = np.array([self.start_position,self.end_position]).T - tck, u = interpolate.splprep( a, u=[0,1], s=0, k=1) - self.position_spline_params = (tck,u) - ## TODO: initialize sensible spline for orientation ## Convenience methods -- GitLab