Exemplo n.º 1
0
    void UpdateOmega(targ_type dt)
    {
        var body_omega = BodyOmega;

        DVector3 body_omega_dt = new DVector3();

        // Euler's equations for torque free motion.
        // Even the the Unity coordinate system is left-handed, this still works.
        // Uses explicit Euler integration...
        body_omega_dt.x = (I.y - I.z) * body_omega.y * body_omega.z / I.x;
        body_omega_dt.y = (I.z - I.x) * body_omega.z * body_omega.x / I.y;
        body_omega_dt.z = (I.x - I.y) * body_omega.x * body_omega.y / I.z;

        body_omega += body_omega_dt * dt;

        BodyOmega = body_omega;

        Debug.Assert(DVector3.Distance(body_omega, DQuaternion.Inverse(Orientation) * Omega) < 1.0e10);
    }