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


C# Coordinates.RotateM90方法代码示例

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


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

示例1: UpdateGridLaneBound

        /// <summary>
        /// Update grid lane bound 
        /// </summary>
        /// <param name="leftBoundPoints">Lane left bound points</param>
        /// <param name="rightBoundPoints">Lane right bound points</param>
        private void UpdateGridLaneBound(IList<LinePath> leftBounds, IList<LinePath> rightBounds)
        {
            StartWatch();	// start stopwatch

            Coordinates extPoint = new Coordinates();
            List<GridCoordinates> gridExtendLocs;

            foreach (LinePath leftBoundPoints in leftBounds) {
                // check if there is at least 2 left bound points
                if (leftBoundPoints.Count > 1) {
                    // find grid lane bound left points
                    FindPoints(leftBoundPoints, out gridLaneBoundLeft);
                    gridLaneBound.SetValues(gridLaneBoundLeft, maxCost);

                    // check if there are grid lane bound left points
                    if (gridLaneBoundLeft.Count != 0) {
                      // extend start of grid left lane bound to grid border
                        extPoint = leftBoundPoints[0] - leftBoundPoints[1];
                        extPoint = leftBoundPoints[0] + extPoint.RotateM90();
                        ExtendPoints(leftBoundPoints[0], extPoint, out gridExtendLocs);
                      gridLaneBound.SetValues(gridExtendLocs, maxCost);

                      // extend end of grid left lane bound to grid border
                      int lastIndex = leftBoundPoints.Count - 1;
                        extPoint = leftBoundPoints[lastIndex] - leftBoundPoints[lastIndex - 1];
                        extPoint = leftBoundPoints[lastIndex] + extPoint.Rotate90().Normalize();
                      ExtendPoints(leftBoundPoints[lastIndex], extPoint, out gridExtendLocs);
                      gridLaneBound.SetValues(gridExtendLocs, maxCost);

                        // floodfill lane bound area
                        List<Coordinates> partialLaneBoundPoints = new List<Coordinates>();
                        partialLaneBoundPoints.Add(leftBoundPoints[lastIndex]);
                        partialLaneBoundPoints.Add(leftBoundPoints[lastIndex - 1]);
                        partialLaneBoundPoints.Add(extPoint);
                        Polygon partialLaneBoundArea = new Polygon(partialLaneBoundPoints);
                        Coordinates partialLaneBoundAreaCenter = partialLaneBoundArea.Center;
                        GridCoordinates partialGridLaneBoundAreaCenter = new GridCoordinates(
                            (int)Math.Round(partialLaneBoundAreaCenter.X / gridStep) + gridMiddleX,
                            (int)Math.Round(partialLaneBoundAreaCenter.Y / gridStep) + gridMiddleY);
                        gridLaneBound.FloodFill(partialGridLaneBoundAreaCenter, maxCost, 0);
                    }
                }
            }

            foreach (LinePath rightBoundPoints in rightBounds) {
                // check if there is at least 2 right bound points
                if (rightBoundPoints.Count > 1) {
                    // find grid lane bound right points
                    FindPoints(rightBoundPoints, out gridLaneBoundRight);
                    gridLaneBound.SetValues(gridLaneBoundRight, maxCost);

                    // check if there are grid lane bound right points
                    if (gridLaneBoundRight.Count != 0) {
                        // extend start of grid right lane bound to grid border
                        extPoint = rightBoundPoints[0] - rightBoundPoints[1];
                        extPoint = rightBoundPoints[0] + extPoint.Rotate90();
                        ExtendPoints(rightBoundPoints[0], extPoint, out gridExtendLocs);
                        gridLaneBound.SetValues(gridExtendLocs, maxCost);

                        // extend end of grid right lane bound to grid border
                        int lastIndex = rightBoundPoints.Count - 1;
                        extPoint = rightBoundPoints[lastIndex] - rightBoundPoints[lastIndex - 1];
                        extPoint = rightBoundPoints[lastIndex] + extPoint.RotateM90().Normalize();
                        ExtendPoints(rightBoundPoints[lastIndex], extPoint, out gridExtendLocs);
                        gridLaneBound.SetValues(gridExtendLocs, maxCost);

                        // floodfill lane bound area
                        List<Coordinates> partialLaneBoundPoints = new List<Coordinates>();
                        partialLaneBoundPoints.Add(rightBoundPoints[lastIndex]);
                        partialLaneBoundPoints.Add(rightBoundPoints[lastIndex - 1]);
                        partialLaneBoundPoints.Add(extPoint);
                        Polygon partialLaneBoundArea = new Polygon(partialLaneBoundPoints);
                        Coordinates partialLaneBoundAreaCenter = partialLaneBoundArea.Center;
                        GridCoordinates partialGridLaneBoundAreaCenter = new GridCoordinates(
                            (int)Math.Round(partialLaneBoundAreaCenter.X / gridStep) + gridMiddleX,
                            (int)Math.Round(partialLaneBoundAreaCenter.Y / gridStep) + gridMiddleY);
                        gridLaneBound.FloodFill(partialGridLaneBoundAreaCenter, maxCost, 0);
                    }
                }
            }

            // generate grid lane bound using wavefront propagation
            float sepDist = 1;	// in m
            float step = maxCost * gridStep / sepDist;
            //gridLaneBound.WaveFront(maxCost, 0, -step);

            // display time to process grid lane bound
            gridLaneBoundTime = StopWatch("ObstacleManager - GridLaneBound - ");

            // write grid data to file (for debugging)
            if (writeToFileFlag == true) {
                StartWatch();
                gridLaneBound.WriteGridToFile("GridLaneBound.txt");
                StopWatch("ObstacleManager - GridLaneBound File Write - ");
            }
//.........这里部分代码省略.........
开发者ID:anand-ajmera,项目名称:cornell-urban-challenge,代码行数:101,代码来源:ObstacleManager.cs

示例2: InflatePartition

 /// <summary>
 /// 
 /// </summary>
 /// <param name="anchor"></param>
 /// <param name="vector"></param>
 /// <param name="width"></param>
 /// <returns></returns>
 private static List<Coordinates> InflatePartition(Coordinates anchor, Coordinates vector, double width)
 {
     List<Coordinates> coordList = new List<Coordinates>();
     Coordinates leftVec = vector.Rotate90().Normalize(width / 2.0);
     Coordinates rightVec = vector.RotateM90().Normalize(width / 2.0);
     coordList.Add(anchor + leftVec);
     coordList.Add(anchor + rightVec);
     coordList.Add(anchor + vector + leftVec);
     coordList.Add(anchor + vector + rightVec);
     return coordList;
 }
开发者ID:anand-ajmera,项目名称:cornell-urban-challenge,代码行数:18,代码来源:IntersectionToolkit.cs


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