From b37c4817192b40e056b9cf49a161c5560d85d2a3 Mon Sep 17 00:00:00 2001 From: Chris Maffeo <cmaffeo2@illinois.edu> Date: Fri, 6 Jul 2018 15:27:07 -0500 Subject: [PATCH] Updated initial placement of orientation beads --- segmentmodel.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/segmentmodel.py b/segmentmodel.py index 8fa8974..172e21c 100644 --- a/segmentmodel.py +++ b/segmentmodel.py @@ -394,15 +394,23 @@ class Segment(ConnectableElement, Group): def contour_to_orientation(self,s): assert( isinstance(s,float) or isinstance(s,int) or len(s) == 1 ) # TODO make vectorized version orientation = None - if self.start_orientation is not None: - # axis = self.start_orientation.dot( np.array((0,0,1)) ) - if self.quaternion_spline_params is None: - axis = self.contour_to_tangent(s) - orientation = rotationAboutAxis( axis, self.twist_per_nt*self.contour_to_nt_pos(s), normalizeAxis=True ) + if self.quaternion_spline_params is None: + axis = self.contour_to_tangent(s) + axis = axis / np.linalg.norm(axis) + rotAxis = np.cross(axis,np.array((0,0,1))) + rotAxisL = np.linalg.norm(rotAxis) + theta = np.arcsin(rotAxisL) + + if rotAxisL > 0.001: + orientation0 = rotationAboutAxis( rotAxis/rotAxisL, theta*180/np.pi, normalizeAxis=False ) else: - q = interpolate.splev( s, self.quaternion_spline_params ) - if len(q) > 1: q = np.array(q).T # TODO: is this needed? - orientation = quaternion_to_matrix(q) + orientation0 = np.eye(3) + orientation = rotationAboutAxis( axis, self.twist_per_nt*self.contour_to_nt_pos(s), normalizeAxis=False ) + orientation = orientation.dot(orientation0) + else: + q = interpolate.splev( s, self.quaternion_spline_params ) + if len(q) > 1: q = np.array(q).T # TODO: is this needed? + orientation = quaternion_to_matrix(q) return orientation def get_contour_sorted_connections_and_locations(self,type_): -- GitLab