head.py 文件源码

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

项目:cebl 作者: idfah 项目源码 文件源码
def plotHeadOutline(ax=None, radius=1.2):
    result = {}

    # if new axis not given, create one
    if ax is None:
        fig = plt.figure(figsize=(11,8))
        result['fig'] = fig
        ax = fig.add_subplot(1,1,1, aspect='equal')
    result['ax'] = ax

    extent = (-0.16-radius,0.16+radius,-0.01-radius,0.20+radius)
    result['extent'] = extent

    ax.set_aspect('equal')
    ax.set_xlim(extent[0], extent[1])
    ax.set_ylim(extent[2], extent[3])

    leftEar = pltPatches.Ellipse((-0.075-radius,0.0), width=0.15, height=0.4, angle=0.0, edgecolor='dimgrey', facecolor='white', linewidth=3, zorder=10, fill=False)
    ax.add_patch(leftEar)

    rightEar = pltPatches.Ellipse((0.075+radius,0.0), width=0.15, height=0.4, angle=0.0, edgecolor='dimgrey', facecolor='white', linewidth=3, zorder=10, fill=False)
    ax.add_patch(rightEar)

    result['leftEar'] = leftEar
    result['rightEar'] = rightEar

    noseLength = 0.18
    noseWidth = 0.12
    noseIntersect = 2.0*radius-np.sqrt(noseWidth**2+radius**2)

    leftNose, = ax.plot((0.0,-noseWidth), (radius+noseLength,noseIntersect), color='dimgrey', linewidth=3, zorder=10)
    rightNose, = ax.plot((0.0,noseWidth), (radius+noseLength,noseIntersect), color='dimgrey', linewidth=3, zorder=10)

    leftNose.set_solid_capstyle('round')
    rightNose.set_solid_capstyle('round')

    result['leftNose'] = leftNose
    result['rightNose'] = rightNose

    head = pltPatches.Circle((0.0,0.0), radius, edgecolor='dimgrey', facecolor='white', linewidth=3, zorder=10, fill=False)
    result['head'] = head
    ax.add_patch(head)

    ax.set_xticks([])
    ax.set_yticks([])

    return result
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号