【发布时间】:2014-01-08 00:29:15
【问题描述】:
我正在学习处理并尝试使用帕斯卡三角形生成分形。这需要PVectors 的数组。我遇到了一个我不明白的问题——我收到了cannot convert from void to PVector
这是一个摘录,并非每个变量都在摘录中定义,但我认为问题可能在于我不需要透露比这更多的代码 - 显示的更多代码可能只会混淆问题。
arrayCopy(points,old_points);
points = new PVector[int(pow(2, j))];
if (j == 1)
{
points[0] = new PVector(0,0);
}
if (j == 2)
{
points[0] = new PVector(1,0);
points[1] = new PVector(-1,0);
}
else
{
//j will be 3 for the THIRD term in the series
int number_of_terms_to_fill = int(pow(j - 1, 2));
int[] pasc = PascalTriangle(j - 1);
float real = findReal(pasc, x, y, number_of_terms_to_fill);
float imagi = findImagi(pasc, x, y, number_of_terms_to_fill);
PVector v = new PVector(real, imagi);
for (int k = 0; k < number_of_terms_to_fill; k = k + 2)
{
points[k] = old_points[k].add(v); //!!***PROBLEM LINE***!!!
points[k+1] = old_points[k].sub(v);
}
}
我的其他函数,比如findReal和findImagi,我相信是正确的。问题行上的加法应该是两个PVectors之间的加法——合法操作。相反,有些东西是无效的?也许arrayCopy 不是我想要的深拷贝?
不知道发生了什么。
【问题讨论】:
标签: processing