//A test of gravity //by Armagon //July 20, 1998 #version 3.1; #include "colors.inc" #declare FramesPerSecond = 10; #declare NumOfSeconds = 6; #declare NumOfFrames = FramesPerSecond * NumOfSeconds; //60 #declare mm = 0.001; // 1 Metre = 1 POV Unit #declare cm = 0.01; #declare m = 1; //OK? I did it. #declare InitialPos = 5 * m; #declare Ground = 0 * m; #declare Rebound = .80; #declare NumOfRebounds = 0; #declare time = clock * NumOfSeconds; #declare vel = 0; #declare g = 9.81; #declare d = -10000; #declare d = (vel * time) - (.5 * g * time * time) * m; // d = vt - .5att d:distance v:velocity a:acceleration (of gravity) t:time #debug concat("Clock: ", str(clock, 5, 4), " Frame: ", str(clock * (NumOfFrames - 1) + 1, 3, 1), "\n") #while (d + (NumOfRebounds=0 ? InitialPos : Ground) < Ground) //#declare InitialPos = Ground; #declare DistFell = (InitialPos-Ground) * pow(Rebound, NumOfRebounds); #declare TimeOfRebound = sqrt(2 * DistFell / g) * m; #declare time = time - TimeOfRebound * (NumOfRebounds = 0 ? 1 : 2); //#declare time = clock * NumOfSeconds - TimeOfRebound * (NumOfRebounds = 0 ? 1 : 2); #declare vel = sqrt(2 * g * DistFell * Rebound); #declare NumOfRebounds = NumOfRebounds + 1; #declare d = ((vel * time) - (.5 * g * time * time)) * m; #debug concat(" InitialPos: ", str(InitialPos, 4, 2), " \tDistFell: ", str(DistFell, 4, 3), "\n") #debug concat(" TimeOfRebound: ", str(TimeOfRebound, 6, 5), " \tTime: ", str(time, 6, 5), "\n") #debug concat(" Actual Time: ", str(clock * NumOfSeconds, 6, 5), " \tNumOfRebounds: ", str(NumOfRebounds, 3, 1), "\n") #debug concat(" Distance: ", str(d, 5, 3), " \tVelocity: ", str(vel, 5, 3), "\n") #debug "\n" #end plane{ y, Ground pigment{Green}} sphere{ y * ( (NumOfRebounds = 0 ? InitialPos : Ground) + d + 20 * cm), 20 * cm pigment{Red} } camera{ //location <0, 2.5 * m, -25 * m> location <7, 5 * m, -7> look_at <0, 2.5 * m, 0> angle 50 //25 //orthographic } light_source{ <10, 40, -20> White } cylinder { <-2, 0, 0>, <-2, 1.65 * m, 0>, .2 * m pigment{Blue} } plane {z, 3 pigment{ checker Yellow, red 1 blue 1 } }