#include #include #include #include "movie.h" #include "putable.h" using namespace std; int main(int argc, char **argv) { const double earth_radius = picture::ymax / 8; const double man_height = earth_radius; const double original_man_height = 3; //distance from center of sun to center of earth const double orbit_radius = picture::ymax - man_height - earth_radius; putable Earth; //Spring (to right of sun) Earth .push_back(putable().circle()) .push_back(putable().semicircle()) .zrot(pi / 2) //daylit hemisphere now to left .scale(earth_radius) .translate(orbit_radius); //to right of sun putable man; man //head .push_back(putable().circle() .scale(.5) .translate(xyz(0, 2.5)) ) //body .push_back(putable().line() .zrot(pi / 2) .translate(xyz(0, 1)) ) //arms .push_back(putable().line() .scale(2) .translate(xyz(-1, 1.5)) ) //right leg .push_back(putable().line() .scale(sqrt(2) * 9 / 10) .zrot(-pi / 4) .translate(xyz(0, 1)) ) //left leg .push_back(putable().line() .scale(sqrt(2) * 9 / 10) .zrot(pi * 5 / 4) .translate(xyz(0, 1)) ) .scale(man_height / original_man_height); picture empty; picture sun_picture; putable Sun; Sun .push_back(putable().sphere()) .scale(picture::ymax / 6.0); sun_picture << Sun; movie(empty, sun_picture).write( "fade_in_sun.gif", "empty", "sun"); picture earth_picture; earth_picture << Sun << Earth; movie(sun_picture, earth_picture).write( "fade_in_earth.gif", "sun", "earth"); picture noon_picture; noon_picture << Sun << Earth << //noon man putable(man) .zrot(pi / 2) .translate(orbit_radius - earth_radius); movie(earth_picture, noon_picture).write( "fade_in_noon.gif", "earth", "noon"); //Man is carried counterclockwise from noon to midnight. movie rotate_to_midnight( constant(xyz(0, 0, picture::dmax)), constant(xyz()), constant(picture::dmax) ); #if 0 cerr << "rotate_to_midnight.nframes == " << rotate_to_midnight.nframes << "\n" << "rotate_to_midnight.v.size() == " << rotate_to_midnight.v.size() << "\n"; #endif rotate_to_midnight << Sun << Earth << putable(man) .zrot(pi / 2) .translate(-earth_radius) .zrot(0, pi) .translate(orbit_radius); rotate_to_midnight.write( "rotate_to_midnight.gif", "noon", "rotate to midnight"); putable midnight; midnight .push_back(Earth) .push_back(putable(man) .zrot(-pi / 2) .translate(orbit_radius + earth_radius) ); putable spring_midnight = midnight; putable summer_midnight = midnight; //Summer earth is above sun. summer_midnight.zrot(pi / 2); putable fall_midnight = midnight; //Fall earth is to left of sun. fall_midnight.zrot(pi); putable winter_midnight = midnight; //Winter earth is below sun. winter_midnight.zrot(3 * pi / 2); movie to_summer( constant(xyz(0, 0, picture::dmax)), constant(xyz()), constant(picture::dmax) ); to_summer << Sun << spring_midnight << putable(spring_midnight).zrot(0, pi/2); to_summer.write( "to_summer.gif", "spring midnight", "summer midnight"); movie to_fall( constant(xyz(0, 0, picture::dmax)), constant(xyz()), constant(picture::dmax) ); to_fall << Sun << spring_midnight << summer_midnight << putable(spring_midnight).zrot(pi / 2, pi); to_fall.write( "to_fall.gif", "summer midnight", "fall midnight"); movie to_winter( constant(xyz(0, 0, picture::dmax)), constant(xyz()), constant(picture::dmax) ); to_winter << Sun << spring_midnight << summer_midnight << fall_midnight << putable(spring_midnight).zrot(pi, 3 * pi / 2); to_winter.write( "to_winter.gif", "fall midnight", "winter midnight"); movie to_sunset( constant(xyz(0, 0, picture::dmax)), constant(xyz()), constant(picture::dmax) ); to_sunset << Sun << Earth << putable(Earth).zrot(pi / 2) << putable(Earth).zrot(pi) << putable(Earth).zrot(3 * pi / 2) << putable(man) //spring .zrot(-pi / 2) .translate(earth_radius) .zrot(0, 3 * pi / 2) .translate(orbit_radius) << putable(man) //summer .zrot(-pi / 2) .translate(earth_radius) .zrot(pi / 2, 2 * pi) .translate(xyz(0, orbit_radius)) << putable(man) //fall .zrot(-pi / 2) .translate(earth_radius) .zrot(pi, 5 * pi / 2) .translate(-orbit_radius) << putable(man) //winter .zrot(-pi / 2) .translate(earth_radius) .zrot(3 * pi / 2, 3 * pi) .translate(xyz(0, -orbit_radius)); to_sunset.write( "to_sunset.gif", "midnights", "sunsets"); #if 0 putable quadrant; //upper quadrant quadrant .push_back(putable().line().zrot( pi / 4)) .push_back(putable().line().zrot(3 * pi / 4)) .scale(original_man_height); putable initial_quadrant = quadrant; quadrant .zrot(pi) .translate(xyz(orbit_radius, - earth_radius - man_height - man_height / original_man_height)); putable moving_quadrant = initial_quadrant; moving_quadrant .translate(xyz(0, 1.5 * man_height / original_man_height)) .zrot(pi, 5 * pi / 4) .translate(xyz(orbit_radius, -earth_radius - 2.5 * man_height / original_man_height)); picture straight_up = to_sunset.v[to_sunset.nframes - 1]; straight_up << initial_quadrant << putable(initial_quadrant).zrot(pi / 2) << putable(initial_quadrant).zrot(pi) << putable(initial_quadrant).zrot(3 * pi / 2); movie(to_sunset.v[to_sunset.nframes - 1], straight_up).write( "straight_up.gif", "sunsets", "quadrants"); movie to_new_quadrants( constant(xyz(0, 0, picture::dmax)), constant(xyz()), constant(picture::dmax) ); to_new_quadrants << Sun << Earth << putable(Earth).zrot(pi / 2) << putable(Earth).zrot(pi) << putable(Earth).zrot(3 * pi / 2) << putable(man) //spring .zrot(-pi / 2) .translate(earth_radius) .zrot(3 * pi / 2) .translate(orbit_radius) << putable(man) //summer .zrot(-pi / 2) .translate(earth_radius) .translate(xyz(0, orbit_radius)) << putable(man) //fall .zrot(-pi / 2) .translate(earth_radius) .zrot(pi / 2) .translate(-orbit_radius) << putable(man) //winter .zrot(-pi / 2) .translate(earth_radius) .zrot(3 * pi / 2) .translate(xyz(0, -orbit_radius)) << moving_quadrant << putable(moving_quadrant).zrot(pi / 2) << putable(moving_quadrant).zrot(pi) << putable(moving_quadrant).zrot(3 * pi / 2); to_new_quadrants.write( "to_new_quadrants.gif", "quadrants", "new quadrants"); #endif movie(to_sunset.v[to_sunset.nframes - 1], empty).write( "fade_out_seasons.gif", "new quadrants", "empty"); return EXIT_SUCCESS; }