// Lutz Tautenhahn (c) 1995, 1999 // Two simple fractal examples in one, try to understand how it works! // The main idea is the recursive coordinate transformation by // translation, rotation, stretching: // Parent ObjectSet={o_1, ..., o_N_Ob} // ->CoordinateTrafo(OperatorSet={o_1, ..., o_N_Op}) // ->Child ObjectSet_1, ..., Child ObjectSet_N_Op // ... ->SubChildren ... ->SubSubChildren #include #include #include #include #define Pi 3.14159265 #define xmin -1.33333 //real x of screen x_min #define xmax 1.33333 //real x of screen x_max #define ymin 0.0 //-1.0 //real y of screen y_min #define ymax 2.0 //1.0 //real y of screen y_max #define N_Op 3 //5 //Number of Operations (coordinate transformations) #define N_Ob 1 //4 //Number of Objects (=lines of the parent shape) int ScreenX(double theRealX) { return(int((theRealX-xmin)/(xmax-xmin)*640)); } int ScreenY(double theRealY) { return(int((ymax-theRealY)/(ymax-ymin)*480)); } struct Vector { double x; double y; double z; }; double ScPr(Vector theVector1, Vector theVector2) { double aDouble; Vector aVec1 = theVector1; Vector aVec2 = theVector2; aDouble = aVec1.x * aVec2.x + aVec1.y * aVec2.y + aVec1.z * aVec2.z; return(aDouble); } struct Object { Vector V[2]; }; struct ObjectSet { Object o[N_Ob]; }; struct Operator { Vector o[3]; }; struct OperatorSet { Operator o[N_Op]; }; void Operation(ObjectSet& aTempObSet, Operator aOp, ObjectSet aObSet) { for (int jj=0; jj0) { for (ii=0; ii