File talk:Swingby dec anim.gif
跳至導覽
跳至搜尋
Source file
[編輯]//swingby.pov for POV-Ray3.6 //SWINGBY-*pseudo*SIMULATION //by Y. Tambe //You can use this source file as Public domain. global_settings { max_trace_level 80 } //light_source (from sol) light_source { <0, 0, 20> rgb <1, 1, 1> shadowless } #declare defaultSceneTypeSet = 0; //0; decelation, 1; accelation #declare finalframe = 60;//number of total step...param_global_1 #declare endcount = 60; #if (clock_on)//for animation #declare endcount = int(clock*finalframe+0.999); #end #declare Gconst = 6.7e-11*(1e-14);//modified with unit...param_global_2 #declare SolPosition = <0,0,0>; //default settings (decelation) #declare PlanetPosition = vaxis_rotate(<20,0,0>,z,8);//param_planet_1 #declare PlanetZrotate = -0.4;//param_planet_2 #declare PlanetWeight = 2e24/6.7;//param_planet_3 #declare PlanetNextPos = vaxis_rotate(PlanetPosition,z,PlanetZrotate); #declare PlanetVelocity = PlanetNextPos -PlanetPosition; #declare ShipPosition = <12.8, 7.2, 0>;//param_ship_1 #declare ShipVelocity = vaxis_rotate(<0.45,0,0>,z,-62);//param_ship_2 #declare ShipWeight = 5;//param_ship_3 #declare ShipSpeed = vlength(ShipVelocity); #declare ShipSpeedRelative = vlength(ShipVelocity-PlanetVelocity); #declare ShipInitialSpeed = ShipSpeed; #declare ShipIniSpeedRel = ShipSpeedRelative; #declare graphON = 1;//plot Ship speed #declare graphRelativeON = 0;//plot Relative speed #declare graph0position = <35, -14, 0>; #declare graphSize = <14,7>; #declare graphXrange = 70; #declare graphYrange = 0.7; #declare graphXticks = graphSize.u/graphXrange; #declare arrowMagnify = 6; #declare arrowShiftAngle = -90; #declare arrowShiftFirst = <-0.4,-0.1,0>; #declare arrowShiftLast = <0,-0.1,0>; #declare cheatON = 0;//cheat ;P #if (defaultSceneTypeSet = 0) //decelation camera { angle 10 location <0.0, 0.0, 180> look_at <0.0, 0.0, 0.0> translate <20,-3,0> } #else //accelation #declare graph0position = <19, -17, 0>; #declare PlanetPosition = vaxis_rotate(<20,0,0>,z,8); #declare ShipPosition = <11.4,2,0>; #declare ShipVelocity = vaxis_rotate(<0.3,0,0>,z,0); #declare ShipSpeed = vlength(ShipVelocity); #declare ShipSpeedRelative = vlength(ShipVelocity-PlanetVelocity); #declare ShipInitialSpeed = ShipSpeed; #declare ShipIniSpeedRel = ShipSpeedRelative; #declare arrowShiftAngle = 90; #declare arrowShiftFirst = <0,-0.3,0>; #declare arrowShiftLast = <-0.5,-0.3,0>; camera { angle 10 location <0.0, 0.0, 180> look_at <0.0, 0.0, 0.0> translate <20,-6,0> } #end //main #declare counter = 0; #while (counter < endcount+1) #declare PlanetNextPos = vaxis_rotate(PlanetPosition,z,PlanetZrotate);//Planet show uniform circular motion: as a simple simulation #declare PlanetVelocity = PlanetNextPos -PlanetPosition; #declare PositionEnergy = -Gconst*ShipWeight*PlanetWeight/(vlength(PlanetPosition-ShipPosition)*vlength(PlanetPosition-ShipPosition) ); #declare ShipVelocity = ShipVelocity +PositionEnergy/ShipWeight*vnormalize(ShipPosition-PlanetPosition); sphere{0, 0.2//Spaceship texture{ pigment{color rgbt<.6,.6,.6,0.9>}//color for trace #if (counter > endcount -0.01) pigment{color rgbt<.0,.5,.9,0>}//color for ship #end finish{ambient 0.4 diffuse 0.6 } } no_shadow translate ShipPosition } //draw trace of Planet: trace every 5 steps #if (mod(counter,5)=0) sphere{0, 1.2//Planet texture{ pigment{color rgbt<.5,.4,.4,0.95>} finish{ambient 0.4 diffuse 0.6} } no_shadow translate PlanetPosition } #end //draw trace of Planet END #declare PlanetPosition = PlanetNextPos; //draw arrow at time0 #if (counter = 0) union{//red arrow for initial velocity of Ship cylinder{ShipPosition, ShipPosition + ShipVelocity *arrowMagnify -vnormalize(ShipVelocity)*.7,0.1} cone{ShipPosition +ShipVelocity* arrowMagnify-vnormalize(ShipVelocity)*.7,0.3,ShipPosition +ShipVelocity* arrowMagnify,0} texture{ pigment{color rgb <.7,0.4,0.4>} finish{ambient 1} } no_shadow translate vnormalize(vaxis_rotate(ShipVelocity,z,arrowShiftAngle) )*1.3 } #if(endcount >finalframe -1 )//on finalframe union{//green arrow for initial velocity of Planet cylinder{ShipPosition, ShipPosition +PlanetVelocity*arrowMagnify*.5,0.1} cone{ShipPosition + PlanetVelocity *arrowMagnify*.5,0.2,ShipPosition + PlanetVelocity * arrowMagnify,0} texture{ pigment{color rgb <0.1,0.5,0.1>} finish{ambient 1} } no_shadow translate vnormalize(vaxis_rotate(ShipVelocity,z,arrowShiftAngle) )*1.3 translate arrowShiftFirst } #declare ShipVelocityRelative = (PlanetVelocity - ShipVelocity); union{//for gray arrow for initial velocity of Ship observed from Planet cylinder{ShipPosition + PlanetVelocity * arrowMagnify, ShipPosition + PlanetVelocity *arrowMagnify-vnormalize(ShipVelocityRelative)*( vlength(ShipVelocityRelative)*arrowMagnify -.9),0.1} cone{ShipPosition + PlanetVelocity * arrowMagnify-vnormalize(ShipVelocityRelative)*( vlength(ShipVelocityRelative)*arrowMagnify -.9) ,0.25,ShipPosition +ShipVelocity* arrowMagnify,0} texture{ pigment{color rgb .4} finish{ambient 1} } no_shadow translate vnormalize(vaxis_rotate(ShipVelocity,z,arrowShiftAngle) )*1.3 translate arrowShiftFirst } #end #end #if (counter > endcount -0.01 )//on endcount of each clock #if(counter > 5)//draw arrow from 5th step union{//red arrow for Ship velocity cylinder{ShipPosition, ShipPosition + ShipVelocity * arrowMagnify-vnormalize(ShipVelocity)*.7,0.1} cone{ShipPosition +ShipVelocity* arrowMagnify-vnormalize(ShipVelocity)*.7,0.3,ShipPosition +ShipVelocity* arrowMagnify,0} texture{ pigment{color rgb <1,0,0>} finish{ambient 1} } no_shadow translate vnormalize(vaxis_rotate(ShipVelocity,z,arrowShiftAngle) ) } #if(endcount > finalframe-1)//on finalframe union{//green arrow for Planet velocity cylinder{ShipPosition, ShipPosition +PlanetVelocity*arrowMagnify*.5,0.1} cone{ShipPosition + PlanetVelocity *arrowMagnify*.5,0.2,ShipPosition + PlanetVelocity * arrowMagnify,0} texture{ pigment{color rgb <0.1,0.5,0.1>} finish{ambient 1} } no_shadow translate vnormalize(vaxis_rotate(ShipVelocity,z,arrowShiftAngle) )*1.3 translate arrowShiftLast } #declare ShipVelocityRelative = (PlanetVelocity - ShipVelocity ); union{//gray arrow for Ship velocity observed from Planet #if(cheatON = 1) //NOTE: this is a cheat because of relative speed is not exact cylinder{ShipPosition + PlanetVelocity * arrowMagnify, ShipPosition + PlanetVelocity *arrowMagnify -vnormalize(ShipVelocityRelative)*(ShipInitialSpeed*arrowMagnify-.9) ,0.1}//cheat ;P cone{ShipPosition + PlanetVelocity * arrowMagnify-vnormalize(ShipVelocityRelative)*(ShipInitialSpeed*arrowMagnify-.9),0.25,ShipPosition +PlanetVelocity* arrowMagnify-vnormalize(ShipVelocityRelative)* ShipInitialSpeed* arrowMagnify,0}//cheat ;P #else cylinder{ShipPosition + PlanetVelocity * arrowMagnify, ShipPosition + PlanetVelocity *arrowMagnify-vnormalize(ShipVelocityRelative)*( vlength(ShipVelocityRelative)*arrowMagnify -.9),0.1} cone{ShipPosition + PlanetVelocity * arrowMagnify-vnormalize(ShipVelocityRelative)*( vlength(ShipVelocityRelative)*arrowMagnify -.9) ,0.25,ShipPosition +ShipVelocity* arrowMagnify,0} #end texture{ pigment{color rgb .4} finish{ambient 1} } no_shadow translate vnormalize(vaxis_rotate(ShipVelocity,z,arrowShiftAngle) )*1.3 translate arrowShiftLast } #end #end #end #declare ShipPosition =ShipPosition+ ShipVelocity; //draw graph line. #if(graphON = 1) //Ship speed observed form sol cylinder{<-counter*graphXticks,ShipSpeed* graphSize.v/graphYrange,0>,<-(counter+1)*graphXticks,vlength(ShipVelocity)* graphSize.v/graphYrange,0>,0.1 texture{ pigment{color rgb <1,0,0>} finish{ambient 1} } no_shadow translate graph0position } #if(graphRelativeON = 1) //Ship speed observed from Planet is not exact because of... //1) Ignoring the change of planet velocity //2) Ignoring the gravitation from Sol to Space ship //and any? cylinder{<-counter *graphXticks,ShipSpeedRelative* graphSize.v/graphYrange,0>,<-(counter+1)*graphXticks,vlength(ShipVelocity-PlanetVelocity)* graphSize.v/graphYrange,0>,0.1 texture{ pigment{color rgb 0.5} finish{ambient 1} } no_shadow translate graph0position } #end #declare ShipSpeedRelative = vlength(ShipVelocity- PlanetVelocity); #declare ShipSpeed = vlength(ShipVelocity); #end #declare counter = counter +1; #end #if(graphON=1) union{//graph frame cylinder{<0,0,0>, <-graphSize.u,0,0>,0.1} cylinder{<0,0,0>, <0,graphSize.v,0>,0.1} texture{ pigment{color rgb 0} finish{ambient 1} } no_shadow translate graph0position } //lines for initial speeds cylinder{<0,ShipInitialSpeed*graphSize.v/graphYrange,0>,<-graphSize.u,ShipInitialSpeed*graphSize.v/graphYrange,0>, 0.06 texture{ pigment{color rgb <0.7,0.4,0.4>} finish{ambient 1} } translate graph0position no_shadow } #if(graphRelativeON = 1) cylinder{<0,ShipIniSpeedRel *graphSize.v/graphYrange,0>,<-graphSize.u,ShipIniSpeedRel *graphSize.v/graphYrange,0>, 0.06 texture{ pigment{color rgb <0.4,0.4,0.4>} finish{ambient 1} } translate graph0position no_shadow } #end #end //draw Planet sphere{0, 1.2 texture{ pigment{color rgb<.5,.4,.4>} finish{ambient 0.4 diffuse 0.6} } translate PlanetPosition no_shadow } //sol... out of scene on default settings, though ;-) sphere{SolPosition,2 texture{ pigment{color rgb<1,.6,0>} finish{ambient 0.8 diffuse 0.2 phong 1 phong_size 1} } } //space plane{-z,0 translate -100*z texture{ pigment{color rgb <0.5,0.5,1>} finish{ambient 1} } }