File:Torus cycles.svg

页面内容不支持其他语言。
這個文件來自維基共享資源
维基百科,自由的百科全书

原始文件(SVG文件,尺寸为512 × 780像素,文件大小:46 KB)


摘要

描述
English: Homology cycles on a torus. Radius of magenta circle is and radius of red circle is . Image created in python and subsequently cropped and rotated manually using a text editor.
日期
来源 自己的作品
作者 Krishnavedala
其他版本
SVG开发
InfoField
 
SVG的源代码为有效代码
 
矢量图使用Matplotlib创作。
源代码
InfoField

Python code

Source code
from mpl_toolkits.mplot3d import axes3d
from matplotlib.patches import Circle
import matplotlib.pyplot as plt
import mpl_toolkits.mplot3d.art3d as art3d
import numpy as np

R, r = 15, 5

def get_x(phi, theta):
    global r, R
    return (R + r * np.cos(phi)) * np.cos(theta)

def get_y(phi, theta):
    global r, R
    return (R + r * np.cos(phi)) * np.sin(theta)

def get_z(phi, theta):
    global r
    return r * np.sin(phi)

if __name__ == "__main__":
    fig = plt.figure(figsize=(10,10))
    ax = fig.add_subplot(111, projection='3d')

    ph = th = np.linspace (-np.pi, np.pi,30)
    phi, theta = np.meshgrid (ph, th)

    x = np.array([get_x(p,t) for p,t in zip(np.ravel(phi), np.ravel(theta))])
    X = x.reshape(phi.shape)
    y = np.array([get_y(p,t) for p,t in zip(np.ravel(phi), np.ravel(theta))])
    Y = y.reshape(phi.shape)
    z = np.array([get_z(p,t) for p,t in zip(np.ravel(phi), np.ravel(theta))])
    Z = z.reshape(phi.shape)
    C1 = Circle( (R,0), radius=r, fc='none', ec='red')
    C2 = Circle( (0,0), radius=R, fc='none', ec='magenta')

    ax.plot_wireframe(X, Y, Z, color='#CCCCCC')
    ax.add_patch(C1)
    ax.add_patch(C2)
    art3d.pathpatch_2d_to_3d(C1, z=0, zdir='y')
    art3d.pathpatch_2d_to_3d(C2, z=r, zdir='z')

    ax.set_xlim3d(-20,20)
    ax.set_ylim3d(-20,20)
    ax.set_zlim3d(-20,20)
    ax.set_xlabel('X')
    ax.set_ylabel('Y')
    ax.set_zlabel('Z')
    ax.set_axis_off()

    ax.view_init(elev=30, azim=-45)
    plt.show()
    plt.savefig('torus.svg', bbox_inches='tight', pad_inches=.15, \
        bbox_extra_artists=[C1,C2], transparent='true')

许可协议

我,本作品著作权人,特此采用以下许可协议发表本作品:
Creative Commons CC-Zero 本作品采用知识共享CC0 1.0 通用公有领域贡献许可协议授权。
采用本宣告发表本作品的人,已在法律允许的范围内,通过在全世界放弃其对本作品拥有的著作权法规定的所有权利(包括所有相关权利),将本作品贡献至公有领域。您可以复制、修改、传播和表演本作品,将其用于商业目的,无需要求授权。

说明

添加一行文字以描述该文件所表现的内容

此文件中描述的项目

描繪內容

文件历史

点击某个日期/时间查看对应时刻的文件。

日期/时间缩⁠略⁠图大小用户备注
当前2014年4月14日 (一) 16:382014年4月14日 (一) 16:38版本的缩略图512 × 780(46 KB)Krishnavedala

以下2个页面使用本文件:

全域文件用途

以下其他wiki使用此文件:

元数据