BEPUphysicsDemos.SampleCode.UprightSpring.IDuringForcesUpdateable C# (CSharp) Method

IDuringForcesUpdateable() private method

Updates the upright constraint. Called automatically by its owning space.
private IDuringForcesUpdateable ( float dt ) : void
dt float Time since last frame in simulation seconds.
return void
        void IDuringForcesUpdateable.Update(float dt)
        {
            myWorldUpVector = Matrix3x3.Transform(myLocalUpVector, Entity.OrientationMatrix);

            //Compute the axis and angle 
            Vector3 axis = Vector3.Cross(myWorldUpVector, Vector3.Up);
            var angle = (float) Math.Acos(Vector3.Dot(Vector3.Up, myWorldUpVector));

            if (angle > MinimumAngle && angle < MaximumAngle)
            {
                angle = angle - MinimumAngle;
                axis.Normalize();
                Entity.AngularMomentum += (axis * (angle * CorrectionFactor * dt));
            }
        }
    }