当前位置: 首页>>代码示例>>C#>>正文


C# Vector.ToAngleInDegrees方法代码示例

本文整理汇总了C#中System.Windows.Vector.ToAngleInDegrees方法的典型用法代码示例。如果您正苦于以下问题:C# Vector.ToAngleInDegrees方法的具体用法?C# Vector.ToAngleInDegrees怎么用?C# Vector.ToAngleInDegrees使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Windows.Vector的用法示例。


在下文中一共展示了Vector.ToAngleInDegrees方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ConvertPathToSensorData

        /// <summary>
        /// Convert the path to sensor data.
        /// </summary>
        /// <returns></returns>
        private Task ConvertPathToSensorData()
        {
            return Task.Run(() =>
            {
                // Initialize poi sensors
                if (PoI.Sensors == null) PoI.Sensors        = new SensorSet();
                csEvents.Sensors.DataSet dataSet;
                PoI.Sensors.TryRemove(KeyLongitude,         out dataSet);
                PoI.Sensors.TryRemove(KeyLatitude,          out dataSet);
                PoI.Sensors.TryRemove(KeyAnimateMove,       out dataSet);
                PoI.Sensors.TryRemove(KeyOrientationSensor, out dataSet);

                foreach (var link in Links)
                {
                    DateTime startTime, endTime;
                    if (!DateTime.TryParse(link.Labels[KeyLabelStartTime], CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out startTime)) return;
                    if (!DateTime.TryParse(link.Labels[KeyLabelEndTime  ], CultureInfo.InvariantCulture, DateTimeStyles.AssumeLocal, out endTime)) return;

                    var totalLength = 0d;
                    var numberOfPoints = link.Points.Count - 1;
                    if (numberOfPoints < 1) continue;
                    var segmentLengths = new double[numberOfPoints];

                    for (var i = 0; i < numberOfPoints; i++)
                    {
                        var p1 = link.Points[i];
                        var p2 = link.Points[i + 1];
                        segmentLengths[i] = ComputeLengthOfSegment(p1, p2);
                        totalLength += segmentLengths[i];
                    }

                    link.Labels[KeyLabelDistance] = totalLength.ToString(CultureInfo.InvariantCulture);

                    var curTime = startTime;
                    // Interpolate linearly along the path between p1 and p2
                    if (totalLength>0)
                    for (var i = 0; i < numberOfPoints; i++)
                    {
                        var p1 = link.Points[i];
                        var p2 = link.Points[i + 1];

                        var lengthOfCurrentSegment   = segmentLengths[i];
                        var durationOfCurrentSegment = TimeSpan.FromTicks((long)((endTime - startTime).Ticks * lengthOfCurrentSegment / totalLength));
                        var endTimeOfCurrentSegment  = curTime + durationOfCurrentSegment;

                        var heading = new Vector(p2.X - p1.X, p2.Y - p1.Y) / durationOfCurrentSegment.TotalSeconds;
                        var currentPoint = p1;
                        PoI.SetSensorValue(curTime, KeyOrientationSensor, heading.ToAngleInDegrees());
                        PoI.SetSensorValue(curTime, KeyAnimateMove, link.Labels.ContainsKey(KeyAnimateMove)
                            ? animations.IndexOf(link.Labels[KeyAnimateMove])
                            : 0);
                        for (var t = curTime; t < endTimeOfCurrentSegment; t += TimeSpan.FromSeconds(1))
                        {
                            PoI.SetSensorValue(t, KeyLongitude, currentPoint.X);
                            PoI.SetSensorValue(t, KeyLatitude, currentPoint.Y);
                            currentPoint += heading; // NOTE: Assumes a stepsize of 1 second
                        }
                        // Reset counters
                        curTime = endTimeOfCurrentSegment;
                    }
                }
                //Model.Service.HasSensorData = PoI.Sensors.ContainsKey(KeyLongitude);
            });
        }
开发者ID:TNOCS,项目名称:csTouch,代码行数:68,代码来源:PathPlannerViewModel.cs


注:本文中的System.Windows.Vector.ToAngleInDegrees方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。