Basic Examples (2)

Create a simple model with a falling ball and a fixed floor:

model=({{, CreatePhysicsModel }})[{
({{, PhysicsBoundaryBox }})[{{-4,-4,0},{4,4,6}},"Thickness"->1],
({{, FixedBody }})[{HatchShading[.6,Blue],Cuboid[{-4,-4,-1},{4,4,0}]}],
({{, DynamicBody }})[{MaterialShading["Gold"],Sphere[{0,0,5},0.6]}]},
]

Plot the model in its initial state:

({{, PhysicsModelPlot }})[model]

Evolve the model for 300 steps with time step 1/60:

frames=({{, PhysicsModelEvolve }})[model,300,1/60];

Generate a video from the frames:

({{, PhysicsModelVideo }})[frames,PlotRange->1.01` {{-5,5},{-5,5},{-1,6}}]

Create a model with four balls with various levels of bounciness:

model=({{, CreatePhysicsModel }})[{({{, PhysicsBoundaryBox }})[{{-4,-4,0},{4,4,6}},"Thickness"->1],({{, FixedBody }})[{HatchShading[.6,Gray],Cuboid[{-4,-4,-1},{4,4,0}]},"Restitution"->1.0],({{, DynamicBody }})[{MaterialShading["Gold"],Sphere[{-2.5,0,5.0},0.5]},"Restitution"->0.95],({{, DynamicBody }})[{MaterialShading["Copper"],Sphere[{-0.8,0,5.0},0.5]},"Restitution"->0.6],({{, DynamicBody }})[{MaterialShading["Silver"],Sphere[{0.8,0,5.0},0.5]},"Restitution"->0.2],({{, DynamicBody }})[{MaterialShading["Brass"],Sphere[{2.5,0,5.0},0.5]},"Restitution"->0.0]},
];

Evolve the model for 300 steps with time step 1/60:

frames=({{, PhysicsModelEvolve }})[model,300,1.0/60.0];

Generate a video from the frames:

({{, PhysicsModelVideo }})[frames,PlotRange->1.03 {{-4,4},{-4,4},{-0.5,6}}]

Create a model with an avalanche of spheres:

model=({{, CreatePhysicsModel }})[{({{, PhysicsBoundaryBox }})[{{-5,-5,-10},{5,5,16}}],({{, FixedBody }})[{Sphere[{0,0,-6},4]}],Flatten@Table[({{, DynamicBody }})[{Sphere[{i,j,k}+RandomReal[{-0.01,0.01},3],0.25]}],{i,-3,3},{j,-3,3},{k,0,14}]},]

Evolve the model for 300 steps with time step 1/60:

frames=({{, PhysicsModelEvolve }})[model,300,1/60];

Generate a video from the frames:

({{, PhysicsModelVideo }})[frames,PlotRange->1.05 {{-7,7},{-7,7},{-10,2}}]

Create a model with a dodecahedron rolling on an inclined plane:

dodecahedron=Translate[ConvexHullMesh[N[PolyhedronData["Dodecahedron","Points"]]],{3,0,5}];
model=({{, CreatePhysicsModel }})[{
({{, DynamicBody }})[{StandardOrange,HatchShading[],dodecahedron}],({{, PhysicsBoundaryBox }})[{{-5,-5,0},{5,5,7}}],({{, FixedBody }})[{Gray,HatchShading[],ConvexHullMesh[{{-5,-5,0},{-5,5,0},{5,5,0},{5,-5,0},{-5,-5,1},{-5,5,1},{5,5,3},{5,-5,3}}]}]},]

Evolve the model for 300 steps with time step 1/60:

frames=({{, PhysicsModelEvolve }})[model,500,1/60.0];

Generate a video from the frames:

({{, PhysicsModelVideo }})[frames,PlotRange->1.01 {{-5,5},{-5,5},{0,7}}]

Create a collection of "dominoes":

dominoes=Table[({{, DynamicBody }})[{MaterialShading["Copper"],Cuboid[{x-0.08,-0.3,0},{x+0.08,0.3,0.8}]}],{x,-3,3,0.6}];

Create a ball that will push over the dominoes:

ball=({{, DynamicBody }})[{MaterialShading["Gold"],Sphere[{-3.8,0,0.4},0.35]},"Density"->5.0,"Velocity"->{3,0,0}];

Create the model from the ball and dominoes:

model=({{, CreatePhysicsModel }})[{({{, PhysicsBoundaryBox }})[{{-4,-4,0},{4,4,6}},"Thickness"->1],({{, FixedBody }})[{HatchShading[.6,Gray],Cuboid[{-4,-4,-1},{4,4,0}]}],dominoes,ball},"Gravity"->{0,0,-9.81},"Graphics3DOptions"->{Background->Black,Axes->False,Boxed->False,ViewPoint->Front,ImageSize->Large}];

Evolve the model for 300 steps with time step 1/60:

frames=({{, PhysicsModelEvolve }})[model,300,1.0/60.0];

Generate a video from the frames:

({{, PhysicsModelVideo }})[frames,PlotRange->1.03 {{-4,4},{-4,4},{-0.5,6}}]

Create a model with a large number of cones:

model=({{, CreatePhysicsModel }})[{({{, PhysicsBoundaryBox }})[{{-4,-4,0},{4,4,6}},"Thickness"->1],({{, FixedBody }})[{HatchShading[.6,Blue],Cuboid[{-4,-4,-1},{4,4,0}]}],({{, FixedBody }})[{HatchShading[.6,Orange],Cylinder[{{-2,-2,0.5},{2,2,0.5}},1.0]}],Table[({{, DynamicBody }})[{MaterialShading["Copper"],Cone[{{i,j,4},{i+RandomReal[{0,0.1}],j+RandomReal[{0,0.1}],5}},0.25]}],{i,-3,3,1},{j,-3,3,1}]},];

Evolve the model for 300 steps with time step 1/60:

frames=({{, PhysicsModelEvolve }})[model,300,1.0/60.0];

Generate a video from the frames:

({{, PhysicsModelVideo }})[frames,PlotRange->1.03 {{-4,4},{-4,4},{-0.5,6}}]