Exemplo n.º 1
0
        public void Move()
        {
            // Use Current Acceleration to Update Veclocity
            double[] _oldVel = Velocity;
            Velocity = LinearAlgebra.VectorAdd(_oldVel, Acceleration);

            // Use Current Velocity to Update Position
            double[] _oldPos = Position;
            Position = LinearAlgebra.VectorAdd(_oldPos, Velocity);
        }
Exemplo n.º 2
0
        private void ComputeAccelerations()
        {
            // Clear all acceleration vectors for step
            for (int i = 0; i < nBodies; i++)
            {
                bodies[i].Acceleration = new double[] { 0.0, 0.0, 0.0, }
            }
            ;

            // Compute Acceleration vectors action on each body
            for (int i = 0; i < nBodies; i++)
            {
                for (int j = 0; j < nBodies; j++)
                {
                    if (i == j)
                    {
                        continue;
                    }                               // Skip if body is the same
                    double[] _oldAcl = bodies[i].Acceleration;
                    double[] _newAcl = Physics.ComputeAcceleration(bodies[i], bodies[j]);
                    bodies[i].Acceleration = LinearAlgebra.VectorAdd(_oldAcl, _newAcl);
                }
            }
        }