|
-
December 23rd, 2014, 12:27 AM
#1
Recursion involving tree with many branches and all branches need to be stored
I want to store all the result which are basically 8 points generated after every time function
GenTestPoint is called.
Can you suggest me how to store all the points generated i.e 4096+512+64+8 points. However, I mainly need the 4096 points which are generated at the end. I am new to programming, not much familiar with pointer and all stuff.
Its start from level 1.
Level 1 = 8 Points;
Level 2 = 64 points;
Level 3 = 512 Points;
Level 4 = 4096 points;
8 points will be calculated only when if statement is true. But it's fine in the worst case all the statements are true and at the end we will get 4096 points. Just consider that all the if statements are true and I am getting 4096 points at the end which I need to store in some GLOBAL Variable.
I need this 4096 points at the end, but even if you can suggest me to store all the points at the end, then also its good.
void GenTestPoint(Vec3f test, float level)
{
float new_denominator = pow(2.0f,level);
Vec3f result1, result2, result3, result4, result5, result6, result7, result8;
Vec3f result11, result12, result13, result14, result15, result16, result17, result18;
result1 = (test.x - 1/new_denominator, test.y - 1/new_denominator, test.z - 1/new_denominator);
result2 = (test.x - 1/new_denominator, test.y - 1/new_denominator, test.z + 1/new_denominator);
result3 = (test.x + 1/new_denominator, test.y - 1/new_denominator, test.z + 1/new_denominator);
result4 = (test.x + 1/new_denominator, test.y - 1/new_denominator, test.z - 1/new_denominator);
result5 = (test.x + 1/new_denominator, test.y + 1/new_denominator, test.z - 1/new_denominator);
result6 = (test.x - 1/new_denominator, test.y + 1/new_denominator, test.z - 1/new_denominator);
result7 = (test.x - 1/new_denominator, test.y + 1/new_denominator, test.z + 1/new_denominator);
result8 = (test.x + 1/new_denominator, test.y + 1/new_denominator, test.z + 1/new_denominator);
while (level < 5)
{
if (CheckInOut(result1)= true)
GenTestPoint(result1, level);
else
break;
if (CheckInOut(result2)= true)
GenTestPoint(result2, level);
else
break;
if (CheckInOut(result3) = true)
GenTestPoint(result3, level);
else
break;
if (CheckInOut(result4)= true)
GenTestPoint(result4, level);
else
break;
if (CheckInOut(result5)= true)
GenTestPoint(result5, level);
else
break;
if (CheckInOut(result6)= true)
GenTestPoint(result6, level);
else
break;
if (CheckInOut(result7)= true)
GenTestPoint(result7, level);
else
break;
if (CheckInOut(result8)= true)
GenTestPoint(result8, level);
else
break;
level = level + 1;
}
}
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|