Example #1
0
 //---------------------------------------------------------------------
 public bool IsBetween(EbAngle kLeft, EbAngle kRight)
 {
     if (kLeft.Value <= kRight.Value)
     {
         return(kLeft.Value <= Value && Value <= kRight.Value);
     }
     else
     {
         return(kLeft.Value <= Value || Value <= kRight.Value);
     }
 }
Example #2
0
 //---------------------------------------------------------------------
 public static float SameSignAngle(EbAngle angle, EbAngle record)
 {
     if (angle.Value > record.Value + EbMath.PI)
     {
         return angle.Value - EbMath.PI_X2;
     }
     else if (angle.Value < record.Value - EbMath.PI)
     {
         return angle.Value + EbMath.PI_X2;
     }
     else
     {
         return angle.Value;
     }
 }
Example #3
0
 //---------------------------------------------------------------------
 public static float SameSignAngle(EbAngle angle, EbAngle record)
 {
     if (angle.Value > record.Value + EbMath.PI)
     {
         return(angle.Value - EbMath.PI_X2);
     }
     else if (angle.Value < record.Value - EbMath.PI)
     {
         return(angle.Value + EbMath.PI_X2);
     }
     else
     {
         return(angle.Value);
     }
 }
Example #4
0
 //---------------------------------------------------------------------
 public static float Diff(EbAngle from, EbAngle to)
 {
     float fDiff = from.Value - to.Value;
     if (fDiff < -EbMath.PI)
     {
         return fDiff + EbMath.PI_X2;
     }
     else if (fDiff >= EbMath.PI)
     {
         return fDiff - EbMath.PI_X2;
     }
     else
     {
         return fDiff;
     }
 }
Example #5
0
        //---------------------------------------------------------------------
        public static float Diff(EbAngle from, EbAngle to)
        {
            float fDiff = from.Value - to.Value;

            if (fDiff < -EbMath.PI)
            {
                return(fDiff + EbMath.PI_X2);
            }
            else if (fDiff >= EbMath.PI)
            {
                return(fDiff - EbMath.PI_X2);
            }
            else
            {
                return(fDiff);
            }
        }
Example #6
0
        //---------------------------------------------------------------------
        public bool Update(float deltaTime, float newDir)
        {
            if (newDir == _curDiretion)
            {
                return(false);
            }
            float maxRot     = deltaTime * _rotSpd;
            float deltaAngle = newDir - _curDiretion;

            EbAngle.Normalize(ref deltaAngle);
            if (Math.Abs(deltaAngle) < maxRot)
            {
                _curDiretion = newDir;
            }
            else
            {
                _curDiretion += maxRot * EbMath.Sign(deltaAngle);
            }
            EbAngle.Normalize(ref _curDiretion);
            return(true);
        }
Example #7
0
        //---------------------------------------------------------------------
        public bool Update(float deltaTime, float newDir)
        {
            float deltaAngle = newDir - _curDiretion;

            if (deltaAngle == 0.0f)
            {
                return(false);
            }
            EbAngle.Normalize(ref deltaAngle);
            float maxRot = 0.0f;

            if (deltaAngle > 0.0f)
            {
                _currentSpeed = Math.Abs(_currentSpeed);
                float newSpd = _currentSpeed + _accelerate * deltaTime;
                float maxSpd = EbMath.Sqrt(deltaAngle * _accelerate * 2.0f);
                _currentSpeed = EbMath.Min(EbMath.Min(newSpd, maxSpd), _maxSpeed);
                maxRot        = _currentSpeed * deltaTime;
            }
            else
            {
                _currentSpeed = -Math.Abs(_currentSpeed);
                float newSpd = _currentSpeed - _accelerate * deltaTime;
                float maxSpd = -EbMath.Sqrt(-deltaAngle * _accelerate * 2.0f);
                _currentSpeed = EbMath.Max(EbMath.Max(newSpd, maxSpd), -_maxSpeed);
                maxRot        = _currentSpeed * deltaTime;
            }
            if (Math.Abs(deltaAngle) < Math.Abs(maxRot))
            {
                _curDiretion  = newDir;
                _currentSpeed = 0.0f;
            }
            else
            {
                _curDiretion += maxRot;
            }
            EbAngle.Normalize(ref _curDiretion);
            return(true);
        }
Example #8
0
 //---------------------------------------------------------------------
 public EbAngle(EbAngle rAngle)
 {
     _value = rAngle.Value;
 }
Example #9
0
 //---------------------------------------------------------------------
 public void Lerp(EbAngle a, EbAngle b, float t)
 {
     _value = a.Value * t + SameSignAngle(a, b) * (1 - t);
     Normalize();
 }
Example #10
0
 //---------------------------------------------------------------------
 public bool IsBetween(EbAngle kLeft, EbAngle kRight)
 {
     if (kLeft.Value <= kRight.Value)
     {
         return (kLeft.Value <= Value && Value <= kRight.Value);
     }
     else
     {
         return (kLeft.Value <= Value || Value <= kRight.Value);
     }
 }
Example #11
0
 //---------------------------------------------------------------------
 public EbAngle(EbAngle rAngle)
 {
     _value = rAngle.Value;
 }
Example #12
0
 //---------------------------------------------------------------------
 public void Lerp(EbAngle a, EbAngle b, float t)
 {
     _value = a.Value * t + SameSignAngle(a, b) * (1 - t);
     Normalize();
 }