surfacemesh.py 文件源码

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

项目:hexmachina 作者: dnkrtz 项目源码 文件源码
def diagonalize_curvature(cls, old_u, old_v, ku, kuv, kv, new_norm):
        """Given a curvature tensor, diagonalize to find principal directions and curvatures."""
        # Rotate old coord system to be normal to new.
        r_old_u, r_old_v = cls.rotate_coord_sys(old_u, old_v, new_norm)
        c = 1
        s = 0
        tt = 0
        if not math.isclose(kuv, 0):
            # Jacobi rotation to diagonalize.
            h = 0.5 * (kv - ku) / kuv
            if h < 0:
                tt = 1 / (h - math.sqrt(1 + h*h))
            else:
                tt = 1 / (h + math.sqrt(1 + h*h))
            c = 1 / math.sqrt(1 + tt*tt)
            s = tt * c
        # Compute principal curvatures.
        k1 = ku - tt * kuv
        k2 = kv + tt * kuv

        # Compute principal directions.
        if abs(k1) >= abs(k2):
            pdir1 = c * r_old_u - s * r_old_v
        else:
            k1, k2 = k2, k1 # swap
            pdir1 = s * r_old_u + c * r_old_v
        pdir2 = np.cross(new_norm, pdir1)
        # Return all the things.
        return pdir1, pdir2, k1, k2
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号