public static Quaternion RotateOverTimeFromReferenceFrame(Quaternion rotateThis, Quaternion byThis, Quaternion asIfMeasuredFromThis, float dt)
        {
            Quaternion start = Quaternion.Inverse(asIfMeasuredFromThis) * rotateThis;
            Quaternion rhs   = Euler3.RotateOverTime(start, byThis, dt);

            return(asIfMeasuredFromThis * rhs);
        }
示例#2
0
 public Quaternion GetFutureRotation(float t)
 {
     if (mode == 2)
     {
         return(Euler3.RotateOverTime(euler3, Euler3Speed, t).rotation);
     }
     if (mode == 3)
     {
         return(Euler3.RotateOverTimeLocal(euler3, Euler3Speed, t).rotation);
     }
     return((euler3 + Euler3Speed * t).rotation);
 }
        public static MovementFrame MoveToDirectionWithoutRoll(MovementFrame prevFrame, Euler3 targetEuler3, MovementOptions options)
        {
            Quaternion    rotation        = prevFrame.Euler3Speed.rotation;
            Quaternion    q               = Quaternion.FromToRotation(prevFrame.euler3.direction, targetEuler3.direction);
            Quaternion    lhs             = ScaleWithMax(q, 2f, options.yawMaxSpeed);
            Quaternion    q2              = lhs * Quaternion.Inverse(rotation);
            Quaternion    to              = ScaleWithMax(q2, 8f, options.yawAcceleration);
            Quaternion    changePerSecond = Quaternion.RotateTowards(Quaternion.identity, to, options.yawAcceleration);
            Quaternion    to2             = Euler3.RotateOverTime(rotation, changePerSecond, 0.1f);
            Quaternion    quat            = Quaternion.RotateTowards(Quaternion.identity, to2, options.yawMaxSpeed);
            Euler3        euler3Speed     = Euler3.Rotation(quat);
            Vector3       linearSpeed     = AdvanceLinearSpeed(prevFrame, options);
            Vector3       strafeSpeed     = AdvanceStrafingSpeed(prevFrame, options, 0f, 0f);
            Euler3        nextEuler       = prevFrame.NextEuler3;
            MovementFrame result          = new MovementFrame(prevFrame.nextPosition, nextEuler, linearSpeed, strafeSpeed, euler3Speed);

            result.mode = 2;
            Quaternion rotationDelta = nextEuler.rotation * Quaternion.Inverse(prevFrame.rotation) * Quaternion.identity;

            //result.ActiveThrusterEffects = DetermineThrusterEffects(rotationDelta, 0f, 0f);
            return(result);
        }