axis.py 文件源码

python
阅读 26 收藏 0 点赞 0 评论 0

项目:measure_lens_alignment 作者: oxford-pcs 项目源码 文件源码
def getProjectedAngleInXYPlane(self, z=0, ref_axis=[0,1], centre=[0,0], inDeg=True):    
    '''
      Project the OA vector to z=z, calculate the XY position, construct a 
      2D vector from [centre] to this XY and measure the angle subtended by 
      this vector from [ref_axis] (clockwise).
    '''
    ref_axis = np.array(ref_axis)
    centre = np.array(centre)

    point_vector_from_fit_centre = np.array(self.getXY(z=z)) - centre
    dotP = np.dot(ref_axis, point_vector_from_fit_centre)
    crossP = np.cross(ref_axis, point_vector_from_fit_centre)
    angle = np.arccos(dotP/(np.linalg.norm(ref_axis)*np.linalg.norm(point_vector_from_fit_centre)))

    if np.sign(crossP) > 0:
      angle = (np.pi-angle) + np.pi

    if inDeg:
      dir_v = self._eval_direction_vector()
      return np.degrees(angle)
    else:
      return angle
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号