Example #1
0
        /// <summary> Builds the geodesic.
        /// </summary>
        public void Rebuild()
        {
            if ((Math.Abs(_za.D()) < EPSILON) ||                          // za == origin
                (Math.Abs(_zb.D()) < EPSILON) ||                          // zb == origin
                (Math.Abs((_za.X / _zb.X) - (_za.Y / _zb.Y)) < EPSILON))  // za == lambda.zb
            {
                _type = DrawType.Line;
            }
            else
            {
                _type = DrawType.Arc;

                double __da = 1 + _za.X * _za.X + _za.Y * _za.Y;
                double __db = 1 + _zb.X * _zb.X + _zb.Y * _zb.Y;
                double __dd = 2 * (_za.X * _zb.Y - _zb.X * _za.Y);

                _zo.X = (_zb.Y * __da - _za.Y * __db) / __dd;
                _zo.Y = (_za.X * __db - _zb.X * __da) / __dd;

                double __det = (_zb.X - _zo.X) * (_za.Y - _zo.Y) - (_za.X - _zo.X) * (_zb.Y - _zo.Y);
                double __fa  = _za.Y * (_za.Y - _zo.Y) - _za.X * (_zo.X - _za.X);
                double __fb  = _zb.Y * (_zb.Y - _zo.Y) - _zb.X * (_zo.X - _zb.X);

                _zc.X = ((_za.Y - _zo.Y) * __fb - (_zb.Y - _zo.Y) * __fa) / __det;
                _zc.Y = ((_zo.X - _za.X) * __fb - (_zo.X - _zb.X) * __fa) / __det;
            }
        }
Example #2
0
 private void UpdatePosition(object sender, EventArgs e)
 {
     if (_animatedNode != null)
     {
         _velocity.X *= 0.90;
         _velocity.Y *= 0.90;
         if (_velocity.D() > 0.01)
         {
             this.Translate(_animatedNode.OldCoordinates, _velocity);
         }
         else
         {
             _animatedNode = null;
             this.EndTranslation();
             _view.StartMouseListening();
         }
     }
 }