巴恩斯利蕨数学公式及源码实现

之前在网上看到《不可思议的分形几何》视频,我对视频中的巴恩斯利蕨感兴趣,所以自己就上手用代码实现了。

巴恩斯利蕨数学公式

巴恩斯利蕨数学公式看原视频截图:

巴恩斯利蕨数学公式

巴恩斯利蕨源码实现:

package lyc.spring.fractal;

import javax.swing.*;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;

/**
 * 巴恩斯利蕨
 */
public class BarnsleyFern extends JApplet {
   

    // 画板
    Image image = null;
    // 绘图
    Graphics graphics = null;
    // 画板的尺寸
    int width = 1500, height = 1500;
    // 图片中心坐标点所在位置
    int offsetX = 1000, offsetY = 50;
    // 缓存数据
    int x2 = 0, y2 = 0;
    // 像素数目
    int pixelCounts = 200000;
    // 图片放大倍数
    double magnification = 56;
    // 图像翻转
    int overturnY = 400;
    // 函数出现概率
    private static final int f1 = 1, f2 = 85,f3 = 7;
    // 定义map的键值对
    private static final String X = "x",Y = "y";
    // 创建Map容器
    Map<String,Double> entry = new HashMap<>(),temp = new HashMap<>();

    /**
     * 程序入口
     */
    public void init(){
   
        image = this.createImage(width, height)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值