int main(int argc, char **argv)
{
Component wave = Union::create();
for (int i=0; i<180; i++){
double ang = i*M_PI/180;
double height = 20*sin(ang);
Component cylinder = Cylinder::create( 0.2 , height );
wave = wave + cylinder.translatedCopy( float(i)/5 , 0 , height/2 );
}
IndentWriter writer;
writer << wave;
std::cout << writer;
}
It is quite similar, but instead of using the << operator uses the + operator and avoids declaring the Union as a CompositeComponent.
Could you tell us if it works?. It could be changed in the tutorial if it works on "more" compilers. (I find the << more elegant :P)
Alberto.