pyfrp_geometry_module.py 文件源码

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

项目:PyFRAP 作者: alexblaessle 项目源码 文件源码
def normalByCross(vec1,vec2):

    r"""Returns normalised normal vectors of plane spanned by two vectors.

    Normal vector is computed by:

    .. math:: \mathbf{n} = \frac{\mathbf{v_1} \times \mathbf{v_2}}{|\mathbf{v_1} \times \mathbf{v_2}|}

    .. note:: Will return zero vector if ``vec1`` and ``vec2`` are colinear.

    Args:
        vec1 (numpy.ndarray): Vector 1.
        vec2 (numpy.ndarray): Vector 2.

    Returns:
        numpy.ndarray: Normal vector.
    """

    if checkColinear(vec1,vec2):

        printWarning("Can't compute normal of vectors, they seem to be colinear. Returning zero.")
        return np.zeros(np.shape(vec1))

    return np.cross(vec1,vec2)/np.linalg.norm(np.cross(vec1,vec2))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号