分形曲线实现及扩展:

本文探讨了如何在OpenGL环境中实现分形曲线,包括必要的配置步骤和可能的扩展应用。
摘要由CSDN通过智能技术生成

注意事项:配置好OpenGL环境。

1.Cantor曲线:
//Cantor.h
#include <GL/glut.h>
#include <math.h>
#define PI 3.1415926
void Cantor(float ax, float ay ,float bx, float by ,float n, float d);

//Cantor.cpp
#include"Cantor.h"
/**ax,ay,bx,by 为直线段两端点坐标,n为迭代最小量,d为不同层次线之间距离**/
void Cantor(float ax, float ay ,float bx, float by ,float n, float d){
    if( (bx - ax) < n)
        return ;
    else {
        glBegin(GL_LINES);
            glVertex2f(ax,ay);
            glVertex2f(bx,by);
        glEnd();
        float cx,cy,dx,dy;
        cx = ax + (bx - ax)/3;
        cy = ay + d ;
        dx = bx - (bx - ax)/3;
        dy = by + d;
        ay = ay + d;
        by = by +d;
        Cantor(ax,ay,cx,cy,n,d);
        Cantor(dx,dy,bx,by,n,d);
    }
}
<
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值