Skip to content
Snippets Groups Projects
Commit 3a73f3a5 authored by cmaffeo2's avatar cmaffeo2
Browse files

Updated set_spline routine to include more detail

parent 9b8b7917
No related branches found
No related tags found
No related merge requests found
...@@ -503,11 +503,11 @@ class Segment(ConnectableElement, Group): ...@@ -503,11 +503,11 @@ class Segment(ConnectableElement, Group):
if about is None: if about is None:
## TODO: do this more efficiently ## 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: else:
dr = np.array(about) dr = np.array(about)
## TODO: do this more efficiently ## 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) self.set_splines(u,r)
...@@ -520,10 +520,14 @@ class Segment(ConnectableElement, Group): ...@@ -520,10 +520,14 @@ class Segment(ConnectableElement, Group):
quats = [quaternion_from_matrix(o) for o in orientations] quats = [quaternion_from_matrix(o) for o in orientations]
self.set_orientation_splines(u, quats) 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 self.quaternion_spline_params = None
coords = np.array([self.start_position, self.end_position]) r0 = np.array(self.start_position)[np.newaxis,:]
self.set_splines([0,1], coords) 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): def clear_all(self):
Group.clear_all(self) # TODO: use super? Group.clear_all(self) # TODO: use super?
...@@ -1002,11 +1006,6 @@ class DoubleStrandedSegment(Segment): ...@@ -1002,11 +1006,6 @@ class DoubleStrandedSegment(Segment):
# for l in (self.start5,self.start3,self.end3,self.end5): # for l in (self.start5,self.start3,self.end3,self.end5):
# self.locations.append(l) # 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 ## TODO: initialize sensible spline for orientation
## Convenience methods ## Convenience methods
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment