Draw a Parametric Curve
来源:互联网 发布:西门子工控淘宝旗舰店 编辑:程序博客网 时间:2024/06/07 08:13
import rhinoscriptsyntax as rsimport math# Something really interesting about this script is# that we are passing a function as a parameter函数的参数是一个函数名def DrawParametricCurve(parametric_equation): "Create a interpolated curve based on a parametric equation." # Get the minimum parameter t0 = rs.GetReal("Minimum t value", 0.0) if( t0==None ): return # Get the maximum parameter t1 = rs.GetReal("Maximum t value", 1.0) if( t1==None ): return # Get the number of sampling points to interpolate through count = rs.GetInteger("Number of points", 50, 2) if count<1: return arrPoints = list() #Get the first point point = parametric_equation(t0) arrPoints.append(point) #Get the rest of the points for x in xrange(1,count-2): t = (1.0-(x/count))*t0 + (x/count)*t1 point = parametric_equation(t) arrPoints.append(point) #Get the last point point = parametric_equation(t1) arrPoints.append(point) #Add the curve rs.AddInterpCurve(arrPoints)#Customizable function that solves a parametric equationdef __CalculatePoint(t): x = (4*(1-t)+1*t ) * math.sin(3*6.2832*t) y = (4*(1-t)+1*t ) * math.cos(3*6.2832*t) z = 5*t return x,y,z########################################################################### Check to see if this file is being executed as the "main" python# script instead of being used as a module by some other python script# This allows us to use the module which ever way we want.if( __name__ == "__main__" ): #Call the function passing another function as a parameter DrawParametricCurve(__CalculatePoint)
阅读全文
0 0
- Draw a Parametric Curve
- Matlab绘图——Draw ROC Curve
- Curve
- draw a pig :)
- Draw a Clover
- Draw with a Canvas
- Draw with a Canvas
- 【OpenGL】Draw a Circle
- Elliptic Curve Cryptography: a gentle introduction
- What is the difference between a parametric learning algorithm and a nonparametric learning method?
- osg demo9 draw a quad
- osg demo10 draw a linewidth
- C# 画线 Draw a Line
- UVA 1493 DRAW A MASS
- Direct2D Intro - Draw a BitmapSource
- Java Applet draw a snowman
- VPython - example - A simple 3D sine curve
- A simple implementation of Bézier curve
- iOS-三方库分析
- 头像图片的裁剪和上传
- Java冒泡排序
- 474. Ones and Zeroes
- Git的操作
- Draw a Parametric Curve
- GO之旅(3)
- 关于float有效位数为7位的研究
- SylixOS 定长内存管理
- uva 10082
- iOS-音频
- 页框page
- Python字符串处理:按单词反转
- 8. String to Integer (atoi)