   L-System plant, where am i going wrong?
  Ok this source is fairly simple, But im not sure where im going wrong://generates the lsystemstd::string LSystem(std::string in, int iterations){std::string input = in;std::string output = "";for(int x = 0; x < iterations; x++){for(int i = 0; i < input.length(); i++){switch(input.at(i)){case 'X':output += "F-[[X]+X]+F[+FX]-X";break;case 'F':output += "FF";break;}}input = output;output.clear();}return input;}plots itvoid PlotLSystem(CTextureBuffer *pBuff, std::string input){std::stack<CState> states;float dist = 2.0f;CState prev(256.0f, 1.0f);CState curr(256.0f, 1.0f);D3DXMATRIX rotmat;for(int i = 0; i < input.length() / 50; i++){switch(input.at(i)){case 'F':{prev = curr;//float length =  sin(curr.angle) + cos(curr.angle);//curr.x += ( sin(D3DXToRadian(curr.angle) ) / length ) * dist;//curr.y += ( cos(D3DXToRadian(curr.angle) ) / length )  * dist;curr.pos += curr.dir * dist;PlotLine(pBuff, (int)(prev.pos.x),(int)(prev.pos.y), (int)(curr.pos.x), (int)(curr.pos.y), &CPixelColour(0,128,0,255));}break;case '-':{D3DXMatrixRotationZ(&rotmat, D3DXToRadian(-25.0f));D3DXVec2TransformCoord(&curr.dir, &curr.dir, &rotmat);D3DXVec2Normalize(&curr.dir, &curr.dir);}break;case '+':{D3DXMatrixRotationZ(&rotmat, D3DXToRadian(25.0f));D3DXVec2TransformCoord(&curr.dir, &curr.dir, &rotmat);D3DXVec2Normalize(&curr.dir, &curr.dir);}break;case '[':{states.push(curr);}break;case ']':{curr = states.top();states.pop();}break;case 'X':{}break;//do nothing}}}Now these are the results im getting:expected: Fractal Plant Now, ive played with lsystems before and theyved worked ok. But this isnt for some reason, im not sure if its the way im using a Stack or my rotation?Any help would be much appreciated.   
  Your post got me curious as to what l-systems were. After reading up on them and doing a few examples, I believe the problem is that your not handling the case of the constants. You handle the variables X and F but when it encounters [ - + ] it doesn't preserve it in the string, thus stripping them out each iteration so the sequence looks like XXXXFFXXFFF instead of something thing like F-[[X]][X]]-F ...To make plants you'll need the state operators preserved.Good Luck!-ddn