生成螺旋线形状的随机点
来源:互联网 发布:mmd舞蹈动作数据 编辑:程序博客网 时间:2024/04/30 10:43
#include<stdio.h>#include<stdlib.h>#include<math.h>#include<string.h>#define PI 3.1415926535void generate_spiral();int size_of_point;//the total size of pointsint range;//the range of x and y of all pointsint initial_phase;//decide position of the first pointint cycles;//the number of lapschar filename[200];int main(int argc, char* argv[]){if( argc != 6 ){printf("This program need 5 paremeter to specified by user""\n\tthe first indicate the total size of point(eg. 100,300,500...)""\n\tthe second indicate the range of x and y of all points(hits:10,20...)""\n\tthe third indicate the initial_phase of spiral(hits:60,150,240...)""\n\tthe forth indicate the number of cycles of spiral(hits:3,10,20...)""\n\tthe last one indicate the output filename to save the value of point");exit(0);}size_of_point = atoi(argv[1]);range = atoi(argv[2]);initial_phase = atoi(argv[3]);cycles = atoi(argv[4]);strcat(filename, argv[5]);generate_spiral();return 0;}void generate_spiral(){FILE* fwrite;if( NULL == (fwrite = fopen(filename, "w"))){printf("open file error");exit(0);}int t;double s;double x;double y;double angle;for( t = 1; t <= size_of_point; t++ ){s = range * t/(double)size_of_point;angle = initial_phase + t/(double)size_of_point * 360 * cycles;x = s * cos(angle * PI / 180);y = s * sin(angle * PI / 180);fprintf(fwrite, "%f\t%f\n", x, y);}fclose(fwrite);}
下图为使用改代码使用不同的参数形成的两条螺旋线
0 0
- 生成螺旋线形状的随机点
- 生成不规则的形状
- 用opengl生成螺旋线算法
- 技能的螺旋线
- 螺旋线
- 螺旋线
- 螺旋线
- 均匀的生成圆和三角形内的随机点
- 均匀的生成圆和三角形内的随机点
- android中生成随机点
- 多边形内生成随机点
- 如何按自定义的坐标点生成随机抽样
- 选取截面一圈点然后沿法线生成对应形状的巷道
- D3 生成不同的形状
- OpenGL——点的绘制(使用OpenGL来绘制可旋转坐标系的螺旋线)
- 获取 Graphics 图形 形状的点集合
- 随机码的生成
- 随机字符串的生成
- Matlab如何在图上画包围目标区域的矩形(或圆)
- 营改增后不能抵扣的15种专用发票情形
- C++灵魂所在之---多态的前世与今生
- mac go sublime 3
- 图片宽度为控件宽度,高度按比例缩放
- 生成螺旋线形状的随机点
- C# 使用Parallel并行开发Parallel.For、Parallel.Foreach实例
- 约束总结
- C++之虚函数
- 【Get深一度】高斯白噪声之——散粒噪声(shot noise )
- gulp教程之gulp中文API
- 第十六周阅读程序-7
- SAP中采购订单状态与MRP的关系
- PRO-2 Day1