示例#1
0
    def get_stats_ds(self, vector_ds, sample_distance):
        #TODO: get angular movement for ALL user, store in list structure
        dd = sample_distance
        stats_ds = []
        for vec in vector_ds:
            stats = []
            for idx in range(len(vec)):
                if idx < dd + 2:
                    stats.append([vec[idx][0], 0, 0, 0])
                    continue
                dt = vec[idx][0] - vec[idx - dd][0]
                theta = head_orientation_lib.angle_between(
                    vec[idx][1], vec[idx - dd][1])
                v = theta * 1.0 / dt
                #                 vec[idx][2] = v

                #                 dv = vec[idx][2] - vec[idx-dd][2]
                #                 a = dv * 1.0 / dt
                #                 vec[idx][3] = a
                item = [vec[idx][0], theta, v, 0]
                stats.append(item)
            stats = np.array(stats)
            t_list, dtheta_list, _, _ = (stats[:, i] for i in range(4))
            #stats[:, 2] = np.gradient(dtheta_list, t_list) #calculate velocity incorrectly
            stats[:, 3] = np.gradient(stats[:, 2], t_list)
            stats_ds.append(stats)
        return stats_ds
示例#2
0
    def get_stats_ds0(self, vector_ds, sample_distance):
        # TODO: get angular movement for ALL user, store in list structure
        dd = sample_distance
        stats_ds = []
        for vec in vector_ds:
            stats = []
            for idx in range(len(vec)):
                if idx < dd+2:
                    continue
                dt = vec[idx][0] - vec[idx-dd][0]
                theta = head_orientation_lib.angle_between(vec[idx][1], vec[idx-dd][1])
                v = theta * 1.0 / dt   
                vec[idx][2] = v

                dv = vec[idx][2] - vec[idx-dd][2]
                a = dv * 1.0 / dt
                vec[idx][3] = a
                item = [vec[idx][0], theta, v, a]
                stats.append(item)
            stats = np.array(stats)
            stats_ds.append(stats)
        return stats_ds