RadianToDegree() public static method

弧度转角度
public static RadianToDegree ( double radian ) : double
radian double
return double
Example #1
0
        public static double AngleBetween(Vector2 a, Vector2 b)
        {
            double sin = CrossProduct(a, b);
            double cos = DotProduct(a, b);

            return(MathUtil.RadianToDegree(Math.Atan2(sin, cos)));
        }
Example #2
0
        /// <summary>
        /// Metoda pro vytvoreni elementu z trajektorie
        /// </summary>
        /// <param name="trajectory">Trajektorie pro zpracovani</param>
        /// <returns>Element s trajektorii</returns>
        private static XElement TrajectoryToElement(Trajectory trajectory)
        {
            XElement trajectoryElement      = new XElement("trajectory");
            XElement trajectoryShapeElement = null;

            if (trajectory is CircularOrbit)
            {
                CircularOrbit circOrbit = (CircularOrbit)trajectory;
                trajectoryShapeElement = new XElement("circularOrbit");
                trajectoryShapeElement.Add(new XAttribute("direction", circOrbit.Direction.ToString().ToLower()));
                trajectoryShapeElement.Add(new XAttribute("period", circOrbit.PeriodInSec));
                String initialAngle = Math.Round(MathUtil.RadianToDegree(circOrbit.InitialAngleRad)).ToString("0.0", CultureInfo.InvariantCulture);
                trajectoryShapeElement.Add(new XAttribute("initialAngle", initialAngle));
                trajectoryShapeElement.Add(new XAttribute("radius", circOrbit.Radius));
            }
            else if (trajectory is EllipticOrbit)
            {
                EllipticOrbit elliOrbit = (EllipticOrbit)trajectory;
                trajectoryShapeElement = new XElement("ellipticOrbit");
                trajectoryShapeElement.Add(new XAttribute("direction", elliOrbit.Direction.ToString().ToLower()));
                trajectoryShapeElement.Add(new XAttribute("period", elliOrbit.PeriodInSec));
                trajectoryShapeElement.Add(new XAttribute("a", elliOrbit.A));
                trajectoryShapeElement.Add(new XAttribute("b", elliOrbit.B));
                String angle = Math.Round(MathUtil.RadianToDegree(elliOrbit.RotationAngleInRad)).ToString("0.0", CultureInfo.InvariantCulture);
                trajectoryShapeElement.Add(new XAttribute("angle", angle));
                String initialAngle = Math.Round(MathUtil.RadianToDegree(elliOrbit.InitialAngleRad)).ToString("0.0", CultureInfo.InvariantCulture);
                trajectoryShapeElement.Add(new XAttribute("initialAngle", initialAngle));
            }
            else if (trajectory is Stacionary)
            {
                Stacionary stacOrbit = (Stacionary)trajectory;
                trajectoryShapeElement = new XElement("stacionary");
                trajectoryShapeElement.Add(new XAttribute("x", stacOrbit.X));
                trajectoryShapeElement.Add(new XAttribute("y", stacOrbit.Y));
            }
            trajectoryElement.Add(trajectoryShapeElement);
            return(trajectoryElement);
        }
        public void UpdateVisualizer()
        {
            if (Window == null || !Window.IsVisible)
            {
                return;
            }

            if (!ZetaDia.IsInGame)
            {
                return;
            }

            using (new PerformanceLogger("Visualizer Update"))
            {
                if (DateTime.UtcNow.Subtract(LastRefresh).TotalMilliseconds <= RefreshRateMs || IsPaused)
                {
                    return;
                }

                LastRefresh = DateTime.UtcNow;

                var objects = Core.Targets.ToList();
                foreach (var obj in objects)
                {
                    obj.Position = obj.Position;
                }
                var queryableObjects = ApplySort(objects.AsQueryable());

                Objects = new ObservableCollection <TrinityActor>(queryableObjects);

                if (VisibilityFlags.HasFlag(RadarVisibilityFlags.NotInCache))
                {
                    if (DateTime.UtcNow.Subtract(LastUpdatedNotInCacheObjects).TotalMilliseconds > 150)
                    {
                        NotInCacheObjects            = new List <TrinityActor>(Core.Targets.Ignored);
                        LastUpdatedNotInCacheObjects = DateTime.UtcNow;
                    }
                }
                else
                {
                    NotInCacheObjects.Clear();
                }

                //if (!IsMouseOverGrid)
                //{
                switch (SelectedTab)
                {
                case Tab.Actors:
                    var allobjects = new List <TrinityActor>(Objects);
                    allobjects.AddRange(NotInCacheObjects);
                    AllObjects = new ObservableCollection <TrinityActor>(allobjects);
                    break;

                case Tab.Markers:
                    AllMarkers = new ObservableCollection <TrinityMarker>(Core.Markers);
                    break;

                case Tab.Minimap:
                    AllMinimap = new ObservableCollection <TrinityMinimapIcon>(Core.Minimap.MinimapIcons);
                    break;
                }
                //}
                //else
                //{
                //    Core.Logger.Verbose("Skipping grid update so grid items can be clicked properly");
                //}

                CurrentTarget = TrinityCombat.Targeting.CurrentTarget;
                Player        = Core.Player.Actor;
                if (Player != null)
                {
                    PlayerPositionX = Player.Position.X;
                    PlayerPositionY = Player.Position.Y;
                    PlayerPositionZ = Player.Position.Z;
                    WorldSnoId      = Core.Player.WorldSnoId;
                    LevelAreaSnoId  = Core.Player.LevelAreaId;
                    PlayerRotation  = MathUtil.RadianToDegree(Player.Rotation);
                    IsStuck         = Navigator.StuckHandler.IsStuck;
                    IsBlocked       = PlayerMover.IsBlocked;
                    OnPropertyChanged(nameof(Player));
                }

                if (!_listeningForStatChanges)
                {
                    AddStatChangerListeners();
                }

                OnPropertyChanged(nameof(CurrentTarget));
                //OnPropertyChanged(nameof(SelectedObject));
            }
        }
Example #4
0
        /// <summary>
        /// Metoda vracejici grafiku pro vykresleni
        /// </summary>
        /// <returns>Grafiky pro vykresleni</returns>
        public override Ellipse GetShape()
        {
            Brush   brush         = Brushes.White;
            Ellipse ellipse       = new Ellipse();
            double  a             = 0;
            double  b             = 0;
            double  rotationAngle = 0;
            double  xPos          = Editor.dataPresenter.DrawingAreaSize;
            double  yPos          = Editor.dataPresenter.DrawingAreaSize;

            if (Trajectory is CircularOrbit)
            {
                CircularOrbit orbit = (CircularOrbit)Trajectory;
                a = orbit.Radius * Editor.dataPresenter.ObjectSizeRatio;
                b = a;
                //Point2d point = orbit.CalculatePosition(0);
                xPos          -= a;
                yPos          -= b;
                ellipse.Width  = 2 * a;
                ellipse.Height = 2 * b;
            }
            else if (Trajectory is EllipticOrbit)
            {
                //EllipticOrbit orbit1 = this.startNavPoint.Location.Trajectory as EllipticOrbit;

                EllipticOrbit orbit = (EllipticOrbit)Trajectory;
                double        cx    = orbit.Cx * Editor.dataPresenter.ObjectSizeRatio;
                double        cy    = orbit.Cy * Editor.dataPresenter.ObjectSizeRatio;
                //setting ellipse
                ellipse.Width  = 2 * orbit.A * Editor.dataPresenter.ObjectSizeRatio;
                ellipse.Height = 2 * orbit.B * Editor.dataPresenter.ObjectSizeRatio;
                //transformation prepare
                TransformGroup transformations = new TransformGroup();
                //translation
                TranslateTransform translate = new TranslateTransform(cx, cy);
                transformations.Children.Add(translate);
                //rotation
                rotationAngle = MathUtil.RadianToDegree(orbit.RotationAngleInRad);
                RotateTransform rotateTransform = new RotateTransform(-rotationAngle);
                rotateTransform.CenterX = (orbit.A - orbit.OrbitalEccentricity) * Editor.dataPresenter.ObjectSizeRatio;
                rotateTransform.CenterY = (orbit.B) * Editor.dataPresenter.ObjectSizeRatio;
                transformations.Children.Add(rotateTransform);
                //finishing transformation
                ellipse.RenderTransform = transformations;
                brush = Brushes.Wheat;
                //setting drawing position
                xPos -= orbit.A * Editor.dataPresenter.ObjectSizeRatio;
                yPos -= orbit.B * Editor.dataPresenter.ObjectSizeRatio;
                #region junk
                //gr.RotateTransform((float)MathUtil.RadianToDegree(orbit.RotationAngleInRad));
                //gr.TranslateTransform(cx, 0); //vycentrování elipsy
                //this.DrawEllipse(gr, orbitPen, 0, 0, orbit.A, orbit.B);
                //gr.TranslateTransform(-cx, 0); //vrácení zpět
                //gr.RotateTransform(-(float)MathUtil.RadianToDegree(orbit.RotationAngleInRad));
                //a = orbit.Cx;
                //b = orbit.Cy;
                #endregion
            }
            else
            {
                throw new ArgumentException("Invalid trajectory");
            }
            //a = (int)(a * Editor.dataPresenter.ObjectSizeRatio);
            //b = (int)(b * Editor.dataPresenter.ObjectSizeRatio);
            //a,b = semi-axis
            //placement logic
            //Editor.Log("size: " + Editor.dataPresenter.DrawingAreaSize + ", a:" + a);
            //Editor.Log("Trajectory: " + xPos + ":" + yPos);

            ellipse.Stroke          = brush;
            ellipse.StrokeThickness = 1;
            Point2d drawingPoint = new Point2d(xPos, yPos);
            this.Position = drawingPoint;

            return(ellipse);
        }