def compute_vel_theta()

in multiple_futures_prediction/dataset_ngsim.py [0:0]


  def compute_vel_theta(self, hist: torch.Tensor, frac: Optional[float]=0.5) -> Tuple[np.ndarray, np.ndarray]:
    """Estimate velocity and orientation from history trajectory."""
    if hist.shape[0] <= 1:
      return np.array([0.0]), np.array([0.0])
    else:   
      total_wts = 0.0
      counter = 0.0
      vel = theta = 0.0        
      for t in range(hist.shape[0]-1,0,-1):
        counter += 1.0
        wt = np.power(frac, counter)
        total_wts += wt            
        diff = hist[t,:] - hist[t-1,:]            
        vel     += wt*np.linalg.norm(diff)*self.ft_to_m/self.dt
        theta   += wt*np.arctan2(diff[1],diff[0])
      return np.array([vel/total_wts]),  np.array([theta/total_wts])