码迷,mamicode.com
首页 > 其他好文 > 详细

数学图形之球面,椭球面,胶囊体,刺球.

时间:2014-08-09 15:52:28      阅读:301      评论:0      收藏:0      [点我收藏+]

标签:blog   http   os   io   2014   div   html   log   

球与圆很相关,一个是三维,一个是二维,可以参考下:圆,椭圆

 

(1)sphere的第一种写法

vertices = D1:100 D2:100

t = from 0 to (PI*2) D1
r = from 0 to 1 D2

x = 2*r*sin(t)*sqrt(1-r^2)
y = 2*r*cos(t)*sqrt(1-r^2)
z = 1-2*(r^2)

bubuko.com,布布扣

 

球的网格线:

bubuko.com,布布扣


(2)sphere的另两种写法

vertices = dimension1:36 dimension2:72
u = from 0 to (2*PI) dimension1
v = from (-PI*0.5) to (PI*0.5) dimension2
r = 10.0
x = r*cos(v)*sin(u)
y = r*sin(v)
z = r*cos(v)*cos(u)
vertices = dimension1:36 dimension2:72
u = from 0 to (2*PI) dimension1
v = from 0 to (PI) dimension2
r = 10.0
x = r*sin(v)*sin(u)
y = r*cos(v)
z = r*sin(v)*cos(u)

两种写法生成的图形是一样的

bubuko.com,布布扣

 


(3)彩色球

在脚本中给rgb变量设值,就能设置顶点色.

vertices = dimension1:72 dimension2:72

u = from 0 to (2*PI) dimension1
v = from (-PI*0.5) to (PI*0.5) dimension2

x = cos(v)*sin(u)
y = sin(v)
z = cos(v)*cos(u)

a = 10.0

r = (x+1.0)/2
g = (y+1.0)/2
b = (z+1.0)/2

x = a*x
y = a*y
z = a*z

bubuko.com,布布扣


(4)圆弧面

将球的第二维度范围减小,即得到圆弧面

vertices = dimension1:36 dimension2:72
u = from 0 to (2*PI) dimension1
v = from (PI*0.1) to (PI*0.5) dimension2
r = 10.0
x = r*cos(v)*sin(u)
y = r*sin(v)
z = r*cos(v)*cos(u)

bubuko.com,布布扣

bubuko.com,布布扣

 

(5)椭球面

#http://www.mathcurve.com/surfaces/ellipsoid/ellipsoid.shtml

vertices = D1:100 D2:100

u = from 0 to (2*PI) D1
v = from (-PI*0.5) to (PI*0.5) D2

a = rand2(1, 10)
b = rand2(1, 10)
c = rand2(1, 10)

x = a*cos(v)*sin(u)
y = b*sin(v)
z = c*cos(v)*cos(u)

bubuko.com,布布扣

 

(6)胶囊体

将球面向上下两头拉伸,即得到胶囊体

bubuko.com,布布扣

 

(7)刺球

将球面上顶点到球心的距离,有规律地变化,可以得到多变的球,如刺球

vertices = dimension1:129 dimension2:65

u = from 0 to (2*PI) dimension1
v = from (-PI*0.5) to (PI*0.5) dimension2

n =4

a = from 0 to 128 D1
b = from 0 to 64 D2

t = (mod(a, n) + mod(b, n))/n*4

r = 10.0 + t

x = r*cos(v)*sin(u)
y = r*sin(v)
z = r*cos(v)*cos(u)

bubuko.com,布布扣

数学图形之球面,椭球面,胶囊体,刺球.,布布扣,bubuko.com

数学图形之球面,椭球面,胶囊体,刺球.

标签:blog   http   os   io   2014   div   html   log   

原文地址:http://www.cnblogs.com/iflewless/p/3901121.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!