小编use*_*709的帖子

算术表达式可以作为参数传递给函数以描述其中的逻辑吗?

我正在可视化Mandelbrot集以及其他一些分形,并且有很多重复的代码,但是没有代码重用。

我正在使用的功能之一如下:

/**
 * determines whether a pixel lies in the set
 * @params x, y - x and y coordinates on R/I axes
 * @param c - a complex number
 */
void calculateSet(int x, int y, Complex c) {
    Complex z = c.clone();
    int n = 0;
    for (; n < maxDepth; n++) {
        if (z.dis() > 4) { break; }
        z = z^2 + c;
    }
    // some code using n to color the set
}
Run Code Online (Sandbox Code Playgroud)

这遵循Mandelbrot集:

z_(n+1) …
Run Code Online (Sandbox Code Playgroud)

c++ polymorphism expression class c++03

0
推荐指数
1
解决办法
76
查看次数

标签 统计

c++ ×1

c++03 ×1

class ×1

expression ×1

polymorphism ×1