數學圖形之圓柱面

來源:互聯網
上載者:User

標籤:blog   http   使用   os   io   2014   div   代碼   

(1)圓柱面

vertices = dimension1:72 dimension2:72u = from 0 to (2*PI) dimension1v = from (-5) to (5) dimension2r = 5x = r*cos(u)y = vz = r*sin(u)

(2)任意角度圓柱面

vertices = dimension1:72 dimension2:72u = from (-5) to (5) dimension2v = from 0 to (2*PI) dimension1a = rand2(0, 2*PI)b = rand2(0, 2*PI)c = sin(v)d = cos(v)e = sin(b)f = cos(b)g = sin(a)h = cos(a)x = f*h*d - f*g*c + e*uy = g*d + h*cz = -e*h*d + e*g*c + f*ux = x*5y = y*5z = z*5

代碼中會隨機設定圓柱的旋轉角度

(3)圓柱體

將圓柱面的兩頭封上,產生閉合的圓柱體

vertices = dimension1:72 dimension2:72u = from 0 to (2*PI) dimension1v = from (-5) to (5) dimension2r = if(abs(v) < 4.9, 5, 0)x = r*cos(u)y = vz = r*sin(u)

(4)由曲線產生的圓柱面

#http://www.mathcurve.com/surfaces/cylindrederevolution/cylindrederevolution.shtmlvertices = D1:100 D2:100u = from 0 to (2*PI) D1v = from 0 to (PI) D2a = rand2(1, 10)x = a*cos(u - v)z = a*sin(u - v)y = a*( u+v)

(5)鼓形

為了簡單,對鼓的隆起使用了SIN函數.

vertices = dimension1:72 dimension2:72u = from 0 to (2*PI) dimension1v = from (-1) to (1) dimension2r = 5h = rand2(1, r)t = h*cos(v*PI/2)p = if(t > 0.01, r+t, 0) x = p*cos(u)y = v*hz = p*sin(u)

新的鼓形指令碼,這個比上一個要圓潤得多:

vertices = dimension1:72 dimension2:72u = from 0 to (2*PI) dimension1v = from (-PI/2) to (PI/2) dimension2r = 5h = rand2(1, r)t = h*cos(v)p = if(t > 0.01, r+t, 0) x = p*cos(u)y = h*sin(v)z = p*sin(u)

(6)齒輪

vertices = D1:65 D2: 4u = from 0 to (2*PI) D1v = from -1 to 1 D2k = from 0 to 64 D1m = mod(k, 2)r = 10.0 + m*2a = 0.9b = in_range(v, -a, a)x = r*sin(u)*bz = r*cos(u)*by = if(b, v, v/3)*3

(7)刺柱

vertices = D1:129 D2:65u = from 0 to (2*PI) D1v = from (-20) to (20) D2n = 4a = from 0 to 128 D1b = from 0 to 64 D2t = (mod(a, n) + mod(b, n))/n*4r = 10 + tx = r*cos(u)y = vz = r*sin(u)

(8)蟶形

vertices = D1:100 D2:100u = from 0 to (2*PI) D1v = from -5 to 5 D2r = 5x = r*cos(u)z = r*sin(u)y = x*v

(9)指定方向的圓柱(極座標原理)

vertices = dimension1:72 dimension2:72u = from (0) to (5) dimension2v = from 0 to (2*PI) dimension1a = rand2(-2, 2)b = rand2(-2, 2)c = rand2(-2, 2)ac = sqrt(a*a + c*c)angleY = atan2(ac, b)angleXZ = atan2(a,c)m = cos(v)n = sin(v)e = sin(angleY)f = cos(angleY)g = sin(angleXZ)h = cos(angleXZ)x0 = my0 = u*f - n*ez0 = u*e + n*fx1 = x0*h + z0*gy1 = y0z1 = -x0*g + z0*hx = x1 + ay = y1 + bz = z1 + c

 

(10)指定方向的圓柱(矩陣原理)

vertices = dimension1:72 dimension2:72u = from (0) to (5) dimension2v = from 0 to (2*PI) dimension1a = rand2(-2, 2)b = rand2(-2, 2)c = rand2(-2, 2)len = sqrt(a*a + b*b + c*c)len = max(len, 0.00001)px = a/lenpy = b/lenpz = c/lenqx = 0qy = pzqz = -py len = sqrt(qx*qx + qy*qy + qz*qz)len = max(len, 0.00001)qx = qx/lenqy = qy/lenqz = qz/lenwx = py*qz - pz*qywy = pz*qx - px*qzwz = px*qy - py*qxx0 = cos(v)y0 = uz0 = sin(v)x = x0*wx + y0*px + z0*qx + ay = x0*wy + y0*py + z0*qy + bz = x0*wz + y0*pz + z0*qz + c

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.