日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

ProE常用曲线方程:Python Matplotlib 版本代码(蝴蝶曲线)

發布時間:2023/12/31 python 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ProE常用曲线方程:Python Matplotlib 版本代码(蝴蝶曲线) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

???????? 花紋的生成可以使用貼圖的方式,同樣也可以使用方程,本文列出了幾種常用曲線的方程式,以取代貼圖方式完成特定花紋的生成。

???????? 注意極坐標的使用.................

???????? 前面部分基礎資料,參考:Python:Matplotlib 畫曲線和柱狀圖(Code)

???????? Pyplot教程:https://matplotlib.org/gallery/index.html#pyplots-examples?

?????????

??????? 顧名思義,蝴蝶曲線(Butterfly curve )就是曲線形狀如同蝴蝶。蝴蝶曲線如圖所示,以方程描述,是一條六次平面曲線。如果大家覺得這個太過簡單,別著急,還有第二種。如圖所示,以方程描述,這是一個極坐標方程。通過改變這個方程中的變量θ,可以得到不同形狀與方向的蝴蝶曲線。如果再施以復雜的組合和變換,我們看到的就完全稱得上是一幅藝術品了。

???????

Python代碼:

import numpy as np import matplotlib.pyplot as plt import os,sys,caffeimport matplotlib as mpl from mpl_toolkits.mplot3d import Axes3D #draw lorenz attractor # %matplotlib inline from math import sin, cos, pi import mathdef mainex():#drawSpringCrurve();#畫柱坐標系螺旋曲線#HelicalCurve();#采用柱坐標系#尖螺旋曲線#Votex3D();#phoenixCurve();#ButterflyCurve();#ButterflyNormalCurve();#dicareCurve2d();#WindmillCurve3d();#HelixBallCurve();#球面螺旋線#AppleCurve();#HelixInCircleCurve();#使用scatter,排序有問題seperialHelix();def drawSpringCrurve():#碟形彈簧#圓柱坐標 #方程:#import matplotlib as mpl#from mpl_toolkits.mplot3d import Axes3D#import numpy as np#import matplotlib.pyplot as pltmpl.rcParams['legend.fontsize'] = 10;fig = plt.figure();ax = fig.gca(projection='3d');# Prepare arrays x, y, z#theta = np.linspace(-4 * np.pi, 4 * np.pi, 100)#z = np.linspace(-2, 2, 100)#r = z**2 + 1t = np.arange(0,100,1);r = t*0 +20;theta = t*3600 ;z = np.arange(0,100,1);for i in range(100):z[i] =(sin(3.5*theta[i]-90))+24*t[i];x = r * np.sin(theta);y = r * np.cos(theta);ax.plot(x, y, z, label='SpringCrurve');ax.legend();plt.show();def HelicalCurve():#螺旋曲線#采用柱坐標系t = np.arange(0,100,1);r =t ;theta=10+t*(20*360);z =t*3;x = r * np.sin(theta);y = r * np.cos(theta);mpl.rcParams['legend.fontsize'] = 10;fig = plt.figure();ax = fig.gca(projection='3d');ax.plot(x, y, z, label='HelicalCurve');ax.legend();plt.show();def ButterflyCurve():#蝶形曲線,使用球坐標系#或許公式是錯誤的,應該有更加復雜的公式t = np.arange(0,4,0.01);r = 8 * t;theta = 3.6 * t * 2*1 ;phi = -3.6 * t * 4*1;x = t*1;y = t*1;#z = t*1;z =0for i in range(len(t)):x[i] = r[i] * np.sin(theta[i])*np.cos(phi[i]);y[i] = r[i] * np.sin(theta[i])*np.sin(phi[i]);#z[i] = r[i] * np.cos(theta[i]);mpl.rcParams['legend.fontsize'] = 10;fig = plt.figure();ax = fig.gca(projection='3d');ax.plot(x, y, z, label='ButterflyCurve');#ax.scatter(x, y, z, label='ButterflyCurve');ax.legend();plt.show();def ButterflyNormalCurve():#蝶形曲線,使用球坐標系#或許公式是錯誤的,應該有更加復雜的公式#螺旋曲線#采用柱坐標系#t = np.arange(0,100,1);theta=np.arange(0,6,0.1);#(0,72,0.1);r =theta*0;z =theta*0;x =theta*0;y =theta*0;for i in range(len(theta)):r[i] = np.power(math.e,sin(theta[i]))- 2*cos(4*theta[i]) + np.power( sin(1/24 * (2*theta[i] -pi ) ) , 5 );#x[i] = r[i] * np.sin(theta[i]);#y[i] = r[i] * np.cos(theta[i]);x = r * np.sin(theta);y = r * np.cos(theta);mpl.rcParams['legend.fontsize'] = 10;fig = plt.figure();ax = fig.gca(projection='3d');ax.plot(x, y, z, label='ButterflyNormalCurve');ax.legend();plt.show();def phoenixCurve():#蝶形曲線,使用球坐標系t = np.arange(0,100,1);r = 8 * t;theta = 360 * t * 4 ;phi = -360 * t * 8;x = t*1;y = t*1;z = t*1;for i in range(len(t)):x[i] = r[i] * np.sin(theta[i])*np.cos(phi[i]);y[i] = r[i] * np.sin(theta[i])*np.sin(phi[i]);z[i] = r[i] * np.cos(theta[i]);mpl.rcParams['legend.fontsize'] = 10;fig = plt.figure();ax = fig.gca(projection='3d');ax.plot(x, y, z, label='phoenixCurve');ax.legend();plt.show();def dicareCurve2d():r = np.arange(0, 2, 0.01)theta = 2 * np.pi * rax = plt.subplot(111, projection='polar')ax.plot(theta, r)ax.set_rmax(2)ax.set_rticks([0.5, 1, 1.5, 2]) # Less radial ticksax.set_rlabel_position(-22.5) # Move radial labels away from plotted lineax.grid(True)ax.set_title("dicareCurve2d", va='bottom')plt.show();def WindmillCurve3d():#風車曲線t = np.arange(0,2,0.01);r =t*0+1 ;#r=1 ang =36*t;#ang =360*t;s =2*pi*r*t;x = t*1;y = t*1;for i in range(len(t)):x[i] = s[i]*cos(ang[i]) +s[i]*sin(ang[i]) ;y[i] = s[i]*sin(ang[i]) -s[i]*cos(ang[i]) ;z =t*0;mpl.rcParams['legend.fontsize'] = 10;fig = plt.figure();ax = fig.gca(projection='3d');ax.plot(x, y, z, label='WindmillCurve3d');ax.legend();plt.show();def HelixBallCurve():#螺旋曲線,使用球坐標系t = np.arange(0,2,0.005);r =t*0+4 ;theta =t*1.8 phi =t*3.6*20x = t*1;y = t*1;z = t*1;for i in range(len(t)):x[i] = r[i] * np.sin(theta[i])*np.cos(phi[i]);y[i] = r[i] * np.sin(theta[i])*np.sin(phi[i]);z[i] = r[i] * np.cos(theta[i]);mpl.rcParams['legend.fontsize'] = 10;fig = plt.figure();ax = fig.gca(projection='3d');ax.plot(x, y, z, label='HelixBallCurve');ax.legend();plt.show();def seperialHelix():#螺旋曲線,使用球坐標系t = np.arange(0,2,0.1);n = np.arange(0,2,0.1);r =t*0+4 ;theta =n*1.8 ;phi =n*3.6*20;x = t*0;y = t*0;z = t*0;for i in range(len(t)):x[i] = r[i] * np.sin(theta[i])*np.cos(phi[i]);y[i] = r[i] * np.sin(theta[i])*np.sin(phi[i]);z[i] = r[i] * np.cos(theta[i]);mpl.rcParams['legend.fontsize'] = 10;fig = plt.figure();ax = fig.gca(projection='3d');ax.plot(x, y, z, label='ButterflyCurve');ax.legend();plt.show();def AppleCurve():#螺旋曲線t = np.arange(0,2,0.01);l=2.5 b=2.5 x = t*1;y = t*1;z =0;#z=t*0;n = 36for i in range(len(t)):x[i]=3*b*cos(t[i]*n)+l*cos(3*t[i]*n) y[i]=3*b*sin(t[i]*n)+l*sin(3*t[i]*n)#x = r * np.sin(theta);#y = r * np.cos(theta);mpl.rcParams['legend.fontsize'] = 10;fig = plt.figure();ax = fig.gca(projection='3d');ax.plot(x, y, z, label='AppleCurve');ax.legend();plt.show();def HelixInCircleCurve():#園內螺旋曲線#采用柱坐標系t = np.arange(-1,1,0.01);theta=t*36 ;#360 deta 0.005鳥巢網 #36 deta 0.005 圓內曲線x = t*1;y = t*1;z = t*1;r = t*1;n = 1.2for i in range(len(t)):r[i]=10+10*sin(n*theta[i]);z[i]=2*sin(n*theta[i]);x[i] = r[i] * np.sin(theta[i]);y[i] = r[i] * np.cos(theta[i]);mpl.rcParams['legend.fontsize'] = 3;fig = plt.figure();ax = fig.gca(projection='3d');ax.plot(x, y, z, label='HelixInCircleCurve');#ax.scatter(x, y, z, label='HelixInCircleCurve');ax.legend();plt.show();def Votex3D():def midpoints(x):sl = ()for i in range(x.ndim):x = (x[sl + np.index_exp[:-1]] + x[sl + np.index_exp[1:]]) / 2.0sl += np.index_exp[:]return x# prepare some coordinates, and attach rgb values to eachr, g, b = np.indices((17, 17, 17)) / 16.0rc = midpoints(r)gc = midpoints(g)bc = midpoints(b)# define a sphere about [0.5, 0.5, 0.5]sphere = (rc - 0.5)**2 + (gc - 0.5)**2 + (bc - 0.5)**2 < 0.5**2# combine the color componentscolors = np.zeros(sphere.shape + (3,))colors[..., 0] = rccolors[..., 1] = gccolors[..., 2] = bc# and plot everythingfig = plt.figure();ax = fig.gca(projection='3d');ax.voxels(r, g, b, sphere,facecolors=colors,edgecolors=np.clip(2*colors - 0.5, 0, 1), # brighterlinewidth=0.5);ax.set(xlabel='r', ylabel='g', zlabel='b');plt.show();def drawFiveFlower():theta=np.arange(0,2*np.pi,0.02) #plt.subplot(121,polar=True) #plt.plot(theta,2*np.ones_like(theta),lw=2) #plt.plot(theta,theta/6,'--',lw=2) #plt.subplot(122,polar=True) plt.subplot(111,polar=True) plt.plot(theta,np.cos(5*theta),'--',lw=2) plt.plot(theta,2*np.cos(4*theta),lw=2) plt.rgrids(np.arange(0.5,2,0.5),angle=45) plt.thetagrids([0,45,90]);plt.show(); if __name__ == '__main__':import argparsemainex();

畫圖結果:

???

??


???

???

????



創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的ProE常用曲线方程:Python Matplotlib 版本代码(蝴蝶曲线)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。

主站蜘蛛池模板: 国产一级黄| 午夜操操| 久久久久美女 | 精品国产乱码久久久久久预案 | 狠狠躁日日躁 | 久久中文字幕在线 | 欧美视频在线观看一区二区 | 亚洲综合在线播放 | 91成人亚洲 | 国产美女永久无遮挡 | 亚洲国产极品 | 婷婷综合在线观看 | 国产97视频| 天天爱天天做 | 波多野结衣有码 | 公侵犯人妻一区二区 | 免费看污片的网站 | 白浆av| 激情综合色 | 日韩一区二区三区三四区视频在线观看 | 久久久五月 | 狠狠的色| 国产伦精品一区二区三区网站 | 欧美一级片在线观看 | 国产精品一品二区三区的使用体验 | 51精品国产人成在线观看 | 91欧美一区二区三区 | 中文字幕乱码人妻无码久久95 | 女人18毛片水真多18精品 | 熟女性饥渴一区二区三区 | 美日韩精品一区二区 | 午夜影院在线视频 | 小辣椒福利视频导航 | 天天高潮夜夜爽 | 九色国产| 亚洲成人第一网站 | 久久国产这里只有精品 | 国产亚洲无码精品 | 老熟妇一区二区三区 | 99热免费精品 | 久青草影院 | 日本美女性生活视频 | 久久99精品波多结衣一区 | 欧美一级在线播放 | 岛国av电影在线观看 | 草逼免费视频 | 中文字幕精品一区二区精品 | 国产在线视频网站 | 久久久夜夜 | 狠狠热免费视频 | 国产精品乱码久久久 | 国产精品乱码妇女bbbb | 在线免费看毛片 | 亚洲一区二区国产 | 青娱乐极品视频在线 | 成人午夜黄色 | 丰满人妻一区二区三区大胸 | www..99热 | 亚洲一二区 | 亚洲成人伦理 | 日本免费黄色大片 | 日韩欧美一区二区三区在线观看 | 国产富婆一区二区三区 | 不卡视频在线观看 | 捆绑调教sm束缚网站 | 18精品爽国产白嫩精品 | 人妻少妇精品一区二区 | 成年人免费视频播放 | 91亚洲精品久久久久久久久久久久 | 黄色二级视频 | 在线青草| 国产福利一区二区 | 都市激情自拍 | 久久色播 | 麻豆资源 | 97人妻天天摸天天爽天天 | 中国性老太hd大全69 | 78日本xxxxxxxxx59| 国产一区二区三区成人 | 红桃成人在线 | 秋霞av鲁丝片一区二区 | 精品国产一区二区三区久久久蜜臀 | 四虎视频国产精品免费 | 91视色 | 中文区中文字幕免费看 | 国产蜜臀在线 | 在线成年人视频 | 中国一级免费毛片 | 偷拍老头老太高潮抽搐 | 蜜臀久久精品久久久久 | av合集| 欧美淫| 邻居少妇张开双腿让我爽一夜 | 国产v在线观看 | 性色欲网站人妻丰满中文久久不卡 | 日韩精品视频观看 | 国产成人在线视频免费观看 | 九九视频在线 | 亚洲 欧美 中文字幕 |