Esempio n. 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);
     }
 }
Esempio n. 2
0
        static private void AddParticleStructure(ParticleStructure ps, KinematicsEngine engine)
        {
            // Add projectiles
            foreach (var projectile in ps.Projectiles)
            {
                engine.AddProjectile(projectile);
            }

            // Add connectors
            foreach (var connector in ps.Connectors)
            {
                // Remember to connect it both ways
                engine.AddForce(new FiniteElementConnectorForce(connector.Projectile1, connector.Projectile2, connector.SpringConstant, connector.UnstretchedLength));
                engine.AddForce(new FiniteElementConnectorForce(connector.Projectile2, connector.Projectile1, connector.SpringConstant, connector.UnstretchedLength));
            }
        }
Esempio n. 3
0
        public static void FiniteElement()
        {
            var structure = new ParticleStructure();

            structure.GroundForceOn = true;

            var engine = new StructureEngine();

            engine.Structure = structure;

            var adapter = new FEEngineAdapter(engine);

            VisualizerNamespace.Visualizer.Radius = .1;
            VisualizerNamespace.Visualizer viz = new VisualizerNamespace.Visualizer(adapter);
            viz.SpherePrecision = 40;
            viz.CylinderRadius  = .01;
            viz.TimeIncrement   = .01;
            viz.AddGround(10, new Vector3D(0, 0, 0), "dirt.jpg");

            //viz.Add3DGraph("Center of Mass", (() => viz.Time), structure.CenterOfMass, "Time (s)", "Position (m)");

            addConnectorsToVisualizer(viz, structure, adapter);
            viz.Show();
        }
Esempio n. 4
0
        private static void addConnectorsToVisualizer(VisualizerNamespace.Visualizer viz, ParticleStructure structure,
                                                      FEEngineAdapter adapter)
        {
            var projectiles = adapter.GetProjectiles();

            foreach (var connect in structure.Connectors)
            {
                viz.AddConnector(projectiles[connect.Item1], projectiles[connect.Item2]);
            }
        }