python绘制繁花曲线代码_繁花曲线
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
#include
#include
#include // 引用图形库头文件
#include
#include
#include
#define pi 3.1415926
int fgbs(int n1 ,int n2) {
int hcf, temp, lcm;
hcf = n1;
temp = n2;
while (hcf != temp)
{
if (hcf > temp)
hcf -= temp;
else
temp -= hcf;
}
lcm = (n1 * n2) / hcf;
return lcm;
}
inline void calcDrawingPoint(long & resX, long & resY, long cenX, long centY, float angleRotation, float angleRevolution,float radiusInner,float radiusDraw) {
long innerCenterX = sin(angleRevolution) * radiusInner;
long innerCenterY = cos(angleRevolution) * radiusInner;
long drawX = innerCenterX + sin(angleRotation) * radiusDraw;
long drawY = innerCenterY + cos(angleRotation) * radiusDraw;
resX = cenX + drawX;
resY = centY + drawY;
}
void initRand() {
srand((int)time(0));
}
void swapInteger(int * a, int * b) {
*a += *b;
*b = *a - *b;
*a = *a - *b;;
}
int getNextRandomInteger(int min, int max) {
if (min > max) {
swapInteger(&min, &max);
}
return (rand() % (max - min)) + min;
}
int drawSth() {
float radiusBig = 400;//外轮半径
initgraph(radiusBig * 2, radiusBig * 2, SHOWCONSOLE | NOMINIMIZE); // 创建绘图窗口,大小为 640x480 像素
for (int t = 0; t < 5; t++) {
//float radiusSmall = 105;//内轮半径
float radiusSmall = getNextRandomInteger(40, radiusBig - 20);
//float toSide = 20;//内轮画点边距
float toSide = getNextRandomInteger(3, radiusSmall - 20);
long radiusScale = 10;//角度放大倍数
long stepRadiusScaled = 1;//画图步长
//每圈自传角度 大元等于小圆时,无转动角度,两动抵消,余量为小圆转动圈数,乘以360即为角度(小圆为反向转动)
float innerSelfRadiusPerRound = 0.0 - ((radiusBig - radiusSmall) * 2 * pi / radiusSmall);
//每圈公转角度
float innerPublicRadiusPerRound = 2 * pi;
float toCenter = radiusSmall - toSide;//内轮花点偏心距
//circle(200, 200, 100); // 画圆,圆心(200, 200),半径 100
//circle(radiusBig, radiusBig, radiusBig);
int cr = getNextRandomInteger(10, 255);
int cg = getNextRandomInteger(10, 255);
int cb = getNextRandomInteger(10, 255);
setlinecolor(RGB(cr, cg, cb));
//linerel(10, 10);
//lineto(20, 15);
//lineto(25, 30);
//计算外轮原点
float outCx = radiusBig;
float outCy = radiusBig;
//计算内轮初始原点
//float innerC0x = outCx - radiusBig + radiusSmall;
//float innerC0y = outCy;
float ric = 0;//内轮圆心位置角度
float rid = 0;//内轮画芯位置角度
int gbs = fgbs(radiusBig, radiusSmall);
int pass = gbs / radiusBig;//总共要绕外圈转多少圈
printf("%d\n", pass);
if (pass > 120) {//圈数过大,重来
t--;
continue;
}
//double passed = 0;
long roundStepNum = 360 * radiusScale; //每圆步数
long totalStepNum = roundStepNum * pass;
long currentStepIdx = 0; //当前步数游标
while (currentStepIdx < totalStepNum) {
long dx = 0;
long dy = 0;
ric = (currentStepIdx / (360.0 * radiusScale)) * innerPublicRadiusPerRound;
rid = (currentStepIdx / (360.0 * radiusScale)) * innerSelfRadiusPerRound;
calcDrawingPoint(dx, dy, outCx, outCy, rid, ric, radiusBig - radiusSmall, toCenter);
//printf_s("currentStepIdx:%ld,rid:%f,ric:%f,X:%ld,Y:%ld\n", currentStepIdx,rid,ric, dx, dy);
if (currentStepIdx) {//非第一个点
lineto(dx, dy);
}
else {
printf("moverel\n");
moveto(dx, dy);
lineto(dx, dy);
}
currentStepIdx += stepRadiusScaled;
}
}
_getch(); // 按任意键继续
closegraph(); // 关闭绘图窗口
return 0;
}
int main()
{
initRand();
drawSth();
return 0;
}
python绘制繁花曲线代码_繁花曲线相关推荐
- python画圆弧组成的花瓣代码_用Python绘制个花朵代码示例
用Python绘制个花朵代码示例及解析 #导入turtle模块 import turtle window=turtle.Screen() #创建一个新窗口用于绘图 babbage=turtle.Tur ...
- python画花朵代码_用Python绘制个花朵代码示例
用Python绘制个花朵代码示例及解析 #导入turtle模块 import turtle window=turtle.Screen() #创建一个新窗口用于绘图 babbage=turtle.Tur ...
- python 绘制q-q图代码
python 绘制q-q图代码 今天,我们附上一份python绘制q-q图的代码 简单介绍一下思路 1.首先,我们需要对我们绘制的两份数据排序,然后,用散点图绘制在图例上 2.之后,绘制散点拟合曲线, ...
- Python绘制520表白代码——永恒的心动
一年一度的520又来了,时光往复,祝陪在你身边的人始终如初. 之前整理过Python浪漫表白源码合集(爱心.玫瑰花.照片墙.星空下的告白).情人节表白烟花.教你用Python秀恩爱.撒狗粮-这是我的某 ...
- python怎么画条形图-python绘制条形图方法代码详解
1.首先要绘制一个简单的条形图 import numpy as np import matplotlib.pyplot as plt from matplotlib import mlab from ...
- python话雷达图-PYTHON绘制雷达图代码实例
这篇文章主要介绍了PYTHON绘制雷达图代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 1.雷达图 import matplotlib.py ...
- python绘制雷达图代码实例-PYTHON绘制雷达图代码实例
这篇文章主要介绍了PYTHON绘制雷达图代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 1.雷达图 import matplotlib.py ...
- python画出的雷达图效果-PYTHON绘制雷达图代码实例
这篇文章主要介绍了PYTHON绘制雷达图代码实例,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友可以参考下 1.雷达图 import matplotlib.py ...
- python画柱状图代码-python绘制双柱形图代码实例
图表是比干巴巴的表格更直观的表达,简洁.有力.工作中经常遇到的场景是,有一些数值需要定时的监控,比如服务器的连接数.活跃用户数.点击某个按钮的人数,并且通过邮件或者网页展示出来.当我们想关注比数值本身 ...
最新文章
- 七段数码管段码表共阳_常用数字电路之显示篇数码管
- 20年总结,21年展望
- 成功解决SQL Server软件中出现的18456问题
- python监视键盘_关于键盘监视的库pyHook与pythoncom
- python快速排序算法循环_算法:快速排序的Python实现
- Bringing up interface eth0: Device eth0 does not seem to be present, delaying initialization
- Ubuntu 12.04 安装配置 Apache2
- 高速缓冲存储器(Cache)
- 去年我国科技研发投入1.76万亿元,与美国差距逐年缩小
- matlab输出n个a,输入a,n两个参数,要求输出aaa...a(共n个)的值
- 中国所有省市区的ip经纬度接口
- AtCoder Beginner Contest 224题解 A-G
- vue3学习-vue create报错tunneling socket could not established
- 企业微信 ios 识别二维码 无法直接跳转 (安卓正常)
- Credly 数字证书
- Arduino超声波传感器使用
- 【mysql】设置mysql默认密码
- 德国柏林计算机比赛,震撼!绝地求生世界杯德国柏林开场秀,盛况空前!
- 敦煌莫高窟唐代离婚协议书曝光 用词浪漫煽情
- c#和python_Python3 与 C# 基础语法对比(就当Python和C#基础的普及吧)