c ++ mandelbrot函数导出全黑图像

时间:2015-10-27 04:17:50

标签: c++ mandelbrot

我应该编写一个根据文件导出Mandelbrot图像的程序,但由于某种原因,ppm总是出现黑色。我知道这意味着值总是打印为0,但我不确定为什么。 我正在使用的示例文件就是 -1 1 0.5 -.5

<?xml version="1.0" encoding="UTF-8" ?>
<settings xsi:schemaLocation='http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd'
          xmlns='http://maven.apache.org/SETTINGS/1.0.0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
   <servers>
        <server>
            <id>bintray-yourusername-maven-yourpackagename</id> <!-- same id with the snapshotRepository -->
            <username>yourusername</username>
            <password>your_api_key</password>
        </server>
    </servers>
    <profiles>
        <profile>
            <repositories>
                <repository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray</name>
                    <url>http://jcenter.bintray.com</url>
                </repository>
            </repositories>
            <pluginRepositories>
                <pluginRepository>
                    <snapshots>
                        <enabled>false</enabled>
                    </snapshots>
                    <id>central</id>
                    <name>bintray-plugins</name>
                    <url>http://jcenter.bintray.com</url>
                </pluginRepository>
            </pluginRepositories>
            <id>bintray</id>
        </profile>
    </profiles>
    <activeProfiles>
        <activeProfile>bintray</activeProfile>
    </activeProfiles>
</settings>

1 个答案:

答案 0 :(得分:0)

input中,您正在创建临时对象并将数据读入临时对象。这不会改变main中的对象。

您需要将c1c2input传递给main

void input(Complex& c1, Complex& c2) {
    c1.real = 0;
    c1.imag = 0;
    c2.real = 0;
    c2.imag = 0;
    ifstream fin;
    fin.open("mandelinput.txt");
    fin >> c1.real >> c1.imag >> c2.real >> c2.imag;
}

main中,您有两个类似命名的对象,并为实部和虚部指定值1。我不清楚c1/c2mainc1/c2input之间的关系是什么。但是,您需要使用两个input类型的对象来呼叫Complex。无论他们是c1还是c2,还是其他一些尚未创建的对象,我都不知道。

相关问题