def measure(self):
"""Measure some properties at the same time"""
if self.valid:
cl = self.center_line();
n2 = self.center_index();
# positions
pos_head = cl[0];
pos_tail = cl[1];
pos_center = cl[n2];
# head tail distance:
dist_head_tail = np.linalg.norm(pos_head-pos_tail)
dist_head_center = np.linalg.norm(pos_head-pos_center)
dist_tail_center = np.linalg.norm(pos_tail-pos_center)
#average curvature
xymintp, u = splprep(cl.T, u = None, s = 1.0, per = 0);
dcx, dcy = splev(u, xymintp, der = 1)
d2cx, d2cy = splev(u, xymintp, der = 2)
ck = (dcx * d2cy - dcy * d2cx)/np.power(dcx**2 + dcy**2, 1.5);
curvature_mean = np.mean(ck);
curvature_variation = np.sum(np.abs(ck))
curled = False;
else:
pos_head = np.array([0,0]);
pos_tail = pos_head;
pos_center = pos_head;
# head tail distance:
dist_head_tail = 0.0
dist_head_center = 0.0
dist_tail_center = 0.0
#average curvature
curvature_mean = 0.0;
curvature_variation = 0.0
curled = True;
data = np.hstack([pos_head, pos_tail, pos_center, dist_head_tail, dist_head_center, dist_tail_center, curvature_mean, curvature_variation, curled]);
return data
############################################################################
### Worm shape deformations, Worm motions
评论列表
文章目录