예제 #1
0
 static private void AddConnectorsToVisualizer(ParticleStructure ps, KinematicsVisualization viz)
 {
     foreach (var connector in ps.Connectors)
     {
         var indices = ps.GetIndexOfProjectiles(connector);
         viz.AddTwoParticleConnector(indices.Item1, indices.Item2, ConnectorColor);
     }
 }
예제 #2
0
 private static void AddSurfacesToVisualizer(JayDongMarbleMachine surfaces, KinematicsVisualization visualization)
 {
     foreach (var surface in surfaces.Surfaces)
     {
         foreach (var triangle in surface.Triangles)
         {
             visualization.AddTriangle(triangle);
         }
     }
 }
예제 #3
0
        static internal void RunMarbleMadness()
        {
            var engine = new KinematicsEngine();

            engine.AddForce(new ConstantGravitationForce(engine, new Vector(0, 0, -9.8)));
            var ps       = new YourParticleStructure();
            var surfaces = new JayDongMarbleMachine();

            AddParticleStructure(ps, engine);
            AddSurfaces(surfaces, engine);

            var adapter = new EngineAdapter(engine);

            Sphere3D.NSegments = 40;
            var visualization = new KinematicsVisualization(adapter);

            visualization.Box = true;

            visualization.ConnectorRadiusScale = .1;
            ProjectileAdapter.VisualSize       = .01;

            AddConnectorsToVisualizer(ps, visualization);
            AddSurfacesToVisualizer(surfaces, visualization);

            Timeline.MaximumPoints = 3000;

            var fullViz = new MotionVisualizer(visualization);

            //fullViz.BackgroundFile = "stars.jpg";

            fullViz.Add3DGraph("Position", () => engine.Time, () => ConvertToVector3D(engine.Projectiles[0].Position), "Time (s)", "Position (m)");
            fullViz.Add3DGraph("Velocity", () => engine.Time, () => ConvertToVector3D(engine.Projectiles[0].Velocity), "Time (s)", "Velocity (m/s)");
            fullViz.Add3DGraph("Acceleration", () => engine.Time, () => ConvertToVector3D(engine.Projectiles[0].Acceleration), "Time (s)", "Acceleration (m/s^2)");

            //fullViz.AddSingleGraph("Speed", Colors.Teal, () => engine.Time, (() => engine.Projectiles[0].Velocity.Magnitude),
            //     "Time (s)", "Speed (m/s)");

            fullViz.Show();
        }