# spiral recursion

• 04-06-2011, 05:40 AM
fatmig
spiral recursion
first part does a spiral
second part is in recursion but its not workin
can anyone help

// variables used for ends of lines
int x1 = 0;
int y1 = 0;
int x2 = 0;
int y2 = 0;;

int offset = 5;

// set initial starting values for line
x1 = 200; // find center of width
y1 = 100; // find center of height

// set initial endpoints for line
x2 = x1 + 100;
y2 = y1;

// in a loop draw line and change endpoints
for( int i=0; i<=20; i++) {
myCanvas.drawLine(x1,y1,x2,y2);
x1+=offset;
y2+=offset;
myCanvas.wait(15);
}*/

//This is the recursive method for the draw2 exercise
//recursiveDraw2(200,300,100,100,5,20);

}//end method draw2()

/** Uncomment the method and insert the correct parameters...*/

//Recursive method for draw2 exercise
void recursiveDraw2(int x1,int y1,int x2,int y2,int offset,int i){

if (i==0){
myCanvas.drawLine(x1,y1,x2,y2);
myCanvas.wait(15);
}

else {

//Draw line correspondent to actual iteration
myCanvas.drawLine(x1,y1,x2,y2);
myCanvas.wait(15);

//Draw the next line in a recursive way
recursiveDraw2(x1,y1+offset,x2,y2+offset,offset,i-1);

}
}
• 04-06-2011, 05:47 AM
Junky
[max smart]
Ahh the old "dump your homework and expect someone else to fix it" trick
[/max smart]
• 04-06-2011, 05:58 AM
fatmig
Aaaahhh yes the good ol typical member that has nothing else to do but ...
• 04-06-2011, 06:03 AM
sunde887
But what? I'm dying of suspense.

• 04-06-2011, 06:04 AM
Junky
Ahh yes the stupid n00b who thinks that making snide remarks about those that they are asking for help will work!
• 04-06-2011, 06:10 AM
fatmig
Ah yes ...indeed yes
• 04-06-2011, 06:11 AM
sunde887
Oh boy, war inc.
• 04-06-2011, 06:13 AM
fatmig
It's okay I was looking for ideas. Junky your the man !
• 04-06-2011, 06:23 AM
Junky
If it is ideas you want then here's one: provide more information.
• 04-06-2011, 07:45 AM
DarrylBurke
Many useful ideas here.

db