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


C# Coordinates类代码示例

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


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

示例1: LocalMapCluster

 public LocalMapCluster(Coordinates position, double speed, Coordinates heading, double width)
 {
     this.position = position;
     this.speed = speed;
     this.heading = heading;
     this.width = width;
 }
开发者ID:anand-ajmera,项目名称:cornell-urban-challenge,代码行数:7,代码来源:LocalMapCluster.cs

示例2: CreateRover

        public static Rover CreateRover(string definition)
        {
            if (string.IsNullOrEmpty(definition)) throw new WrongRoverDefinitionException("Definition of rover is empty.");

            var coordinatesAndOrientation = definition.Split(' ');

            if(coordinatesAndOrientation.Length != 3) throw new WrongRoverDefinitionException("Definition of rover doesn't have the proper format.");

            Coordinates coordinates;
            IOrientation orientation;

            try
            {
                coordinates = new Coordinates(Convert.ToInt32(coordinatesAndOrientation[0]),
                                                  Convert.ToInt32(coordinatesAndOrientation[1]));

                orientation = OrientationFactory.GenerateOrientation(coordinatesAndOrientation[2]);
            }
            catch (Exception ex)
            {
                throw new WrongRoverDefinitionException("Bad definition.", ex);
            }

            var rover = new Rover();

            rover.Init(coordinates, orientation);

            return rover;
        }
开发者ID:jruizx,项目名称:MarsRoversProblem,代码行数:29,代码来源:Rover.cs

示例3: ComputeMeanCovariance

        public static void ComputeMeanCovariance(IList<Coordinates> pts, out Coordinates mean, out Matrix2 cov)
        {
            // for better numerical stability, use a two-pass method where we first compute the mean
            double sum_x = 0, sum_y = 0;
            for (int i = 0; i < pts.Count; i++) {
                sum_x += pts[i].X;
                sum_y += pts[i].Y;
            }

            double avg_x = sum_x/(double)pts.Count;
            double avg_y = sum_y/(double)pts.Count;

            // now compute variances and covariances
            double sum_x2 = 0, sum_y2 = 0, sum_xy = 0;
            for (int i = 0; i < pts.Count; i++) {
                double dx = pts[i].X - avg_x;
                double dy = pts[i].Y - avg_y;

                sum_x2 += dx*dx;
                sum_y2 += dy*dy;
                sum_xy += dx*dy;
            }

            double var_x = sum_x2/(double)pts.Count;
            double var_y = sum_y2/(double)pts.Count;
            double cov_xy = sum_xy/(double)pts.Count;

            mean = new Coordinates(avg_x, avg_y);
            cov = new Matrix2(var_x, cov_xy, cov_xy, var_y);
        }
开发者ID:anand-ajmera,项目名称:cornell-urban-challenge,代码行数:30,代码来源:MathUtil.cs

示例4: CreatePolygon

        public static SqlGeography CreatePolygon(Coordinates[] coordinates, int srid)
        {
            var list = coordinates.Distinct().ToList();
            
            var b = new SqlGeographyBuilder();
            b.SetSrid(srid);
            b.BeginGeography(OpenGisGeographyType.Polygon);
            b.BeginFigure(list[0].Latitude, list[0].Longitude);

            for (var i = 1; i < list.Count; i++)
                b.AddLine(list[i].Latitude, list[i].Longitude);

            b.AddLine(list[0].Latitude, list[0].Longitude);
            b.EndFigure();
            b.EndGeography();

            //Fix left-hand rule. We always want left-hand.
            var g = b.ConstructedGeography;
            if (!g.STIsValid())
                throw new SisoDbException(ExceptionMessages.NotAValidPolygon.Inject(g.IsValidDetailed()));

            if (g.EnvelopeAngle() > 90)
                g = g.ReorientObject(); 

            return g;
        }
开发者ID:ovuncgursoy,项目名称:SisoDb-Provider,代码行数:26,代码来源:GeographyFactory.cs

示例5: WillCollideWith

    private bool WillCollideWith(GameObject obj, Coordinates direction, GameObject cur)
    {
        Coordinates first = new Coordinates(
            Math.Max(obj.Position.Row + direction.Row,
                     cur.Position.Row),

            Math.Max(obj.Position.Col + direction.Col,
                     cur.Position.Col)
        );

        Coordinates last = new Coordinates(
            Math.Min(obj.Position.Row + obj.Rows + direction.Row,
                     cur.Position.Row + cur.Rows),

            Math.Min(obj.Position.Col + obj.Cols + direction.Col,
                     cur.Position.Col + cur.Cols)
        );

        for (int row = first.Row; row < last.Row; row++)
            for (int col = first.Col; col < last.Col; col++)
                if (obj[row - obj.Position.Row - direction.Row, col - obj.Position.Col - direction.Col] != '\0' &&
                    cur[row - cur.Position.Row, col - cur.Position.Col] != '\0')
                        return true;

        return false;
    }
开发者ID:hrisita,项目名称:TelerikAcademy,代码行数:26,代码来源:EngineCollisionChecker.cs

示例6: Map

        public Map(PhysicsEngine physicsEngine)
        {
            physicsEngine.AddItem(this);
            this.physicsEngine = physicsEngine;
            RequeredTicksToMove = 3;
            Position = new Coordinates();
            Content = new Dictionary<Coordinates, char>();
            for (int i = 0; i < mapFences.Length; i++)
            {
                mapFences[i] = new char[Globals.Y_MAX_BOARD_SIZE];
                for (int j = 0; j < mapFences[i].Length; j++)
                {
                    mapFences[i][j] = j % 3 == 1 ? Globals.BACKGROUND_DEFAULT_VALUE : '+';
                }
            }
            var jsonText = File.ReadAllText(Globals.MODELS_PATH + "asd" + Globals.MODELS_FILES_EXTENSION);
            var deserializeObject = JsonConvert.DeserializeObject<MapStructure>(jsonText);
            Width = deserializeObject.MapWidth;
            Height = deserializeObject.MapLength;
            foreach (var mapObject in deserializeObject.map)
            {

                switch (mapObject.ClassType)
                {
                    case "Services.Services.Objects.Obsticle":
                        TakeObject(obsticlesFactory, mapObject);
                        break;
                    default:
                        return;
                }
            }
            RecreateFences();
        }
开发者ID:tautvisv,项目名称:NFS3000,代码行数:33,代码来源:Map.cs

示例7: EvaluateGoalUtility

        private static double EvaluateGoalUtility(double curvature, Coordinates relativeGoalPoint)
        {
            // get the angle to the goal point
            double angle = relativeGoalPoint.ArcTan;

            const double angleMax = 45*Math.PI/180.0;
            double scaledAngle = angle/angleMax;
            if (scaledAngle > 1) scaledAngle = 1;
            if (scaledAngle < -1) scaledAngle = -1;

            // calculate the target curvature to hit the goal
            double targetCurvature = scaledAngle*max_curvature;

            // calculate a matching scale factor
            double scaleFactor = Math.Pow((curvature - targetCurvature)/0.01, 2);

            // calculate a distance weighting factor
            double distMin = 20;
            double distMax = 70;
            double distFactor = (relativeGoalPoint.Length - distMin)/(distMax - distMin);
            if (distFactor > 0.3) distFactor = 0.3;
            if (distFactor < 0) distFactor = 0;
            distFactor = 1-distFactor;

            double turnFactor = (1-scaleFactor*0.1);
            if (turnFactor < -1) turnFactor = -1;

            return turnFactor*distFactor;
        }
开发者ID:anand-ajmera,项目名称:cornell-urban-challenge,代码行数:29,代码来源:ZoneArcVoting.cs

示例8: getBlockAt

        public Block getBlockAt(Coordinates coordinates)
        {
            int x = (int)Math.Floor(coordinates.getX());
               int y = (int)Math.Floor(coordinates.getY());

               if(!blocks.ContainsKey(x.ToString() + "," + y.ToString())){
               if (coordinates.getY() > -1) {
                   blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Air()));
               }
               else if (coordinates.getY() == -1) {
                   blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Grass()));
               }
               else if (coordinates.getY() == -2) {
                   Random rnd = new Random();

                   if (rnd.Next(0, 2) == 0) {
                       blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Dirt()));
                   }
                   else {
                       blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Stone()));
                   }
               }
               else if (coordinates.getY() < -2) {
                   blocks.Add(x.ToString() + "," + y.ToString(), new Block(new Stone()));
               }
               blocks[x.ToString() + "," + y.ToString()].setCoordinates(coordinates);
               }

               return blocks[x.ToString() + "," + y.ToString()];
        }
开发者ID:patrickfreed,项目名称:SideCraft--Old-,代码行数:30,代码来源:World.cs

示例9: GetCoordinates

        public JsonResult GetCoordinates(string street, string number)
        {
            var reguestGET =
                WebRequest.Create("http://nominatim.openstreetmap.org/search?q=" + number + "+" + street +
                                  ",+Донецк, Украина&format=xml&addressdetails=1");

            reguestGET.Proxy = null;

            var webResponse = reguestGET.GetResponse();

            var stream = webResponse.GetResponseStream();

            if (stream == null)
            {
                throw new Exception("Can't get response from server.");
            }

            var xmlDoc = new XmlDocument();
            xmlDoc.Load(stream);

            var tagPlace = (XmlElement) xmlDoc.GetElementsByTagName("place")[0];

            if (tagPlace == null)
            {
                return Json(null, JsonRequestBehavior.AllowGet);
            }

            var lat = Convert.ToSingle(tagPlace.GetAttribute("lat"), new CultureInfo("en-US"));
            var lon = Convert.ToSingle(tagPlace.GetAttribute("lon"), new CultureInfo("en-US"));

            var coord = new Coordinates { Lat = lat, Lon = lon };

            return Json(coord, JsonRequestBehavior.AllowGet);
        }
开发者ID:polyLeader,项目名称:HackathonProject,代码行数:34,代码来源:MapController.cs

示例10: WhenACoordinateHasBeenExploredThenIsExploredIsTrue

 public void WhenACoordinateHasBeenExploredThenIsExploredIsTrue()
 {
     var minefield = Minefield.Empty(2, 3);
     var coordinate = new Coordinates(0, 1);
     var exploredMinefield = minefield.Explore(coordinate);
     Assert.AreEqual(true, exploredMinefield.IsExplored(coordinate.RowIndex, coordinate.ColumnIndex));
 }
开发者ID:ferozjilla,项目名称:Minesweeper,代码行数:7,代码来源:MinefieldTests.cs

示例11: getCell

 public WorldCell getCell(Coordinates cell_coords)
 {
     if (checkCoordinateIntegrity (cell_coords)) {
         return cells[cell_coords.x, cell_coords.y];
     }
     return null;
 }
开发者ID:dav793,项目名称:2D-RTS,代码行数:7,代码来源:World.cs

示例12: isEqual

 public bool isEqual(Coordinates coordinate)
 {
     if(coordinate.x == x && coordinate.y == y) {
         return true;
     }
     return false;
 }
开发者ID:dav793,项目名称:2D-RTS,代码行数:7,代码来源:RenderedCells.cs

示例13: LinePathSegment

 public LinePathSegment(Coordinates start, Coordinates end, double? endSpeed, bool? stopline)
 {
     this.start = start;
     this.end = end;
     this.endSpeed = endSpeed;
     this.stopline = stopline;
 }
开发者ID:anand-ajmera,项目名称:cornell-urban-challenge,代码行数:7,代码来源:LinePathSegment.cs

示例14: ClearForDisabledVehiclePass

        /// <summary>
        /// Checks if hte opposing lane is clear to pass an opposing vehicle
        /// </summary>
        /// <param name="lane"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public bool ClearForDisabledVehiclePass(ArbiterLane lane, VehicleState state, double vUs, Coordinates minReturn)
        {
            // update the forward vehicle
            this.ForwardVehicle.Update(lane, state);

            // check if the rear vehicle exists and is moving along with us
            if (this.ForwardVehicle.ShouldUseForwardTracker && this.ForwardVehicle.CurrentVehicle != null)
            {
                // distance from other to us
                double currentDistance = lane.DistanceBetween(this.ForwardVehicle.CurrentVehicle.ClosestPosition, state.Front) - (2 * TahoeParams.VL);
                double minChangeDist = lane.DistanceBetween(minReturn, state.Front);

                // check if he's within min return dist
                if(currentDistance > minChangeDist)
                {
                    // params
                    double vOther = this.ForwardVehicle.CurrentVehicle.StateMonitor.Observed.speedValid ? this.ForwardVehicle.CurrentVehicle.Speed : lane.Way.Segment.SpeedLimits.MaximumSpeed;

                    // get distance of envelope for him to slow to our speed
                    double xEnvelope = (Math.Pow(vUs, 2.0) - Math.Pow(vOther, 2.0)) / (2.0 * -0.5);

                    // check to see if vehicle is outside of the envelope to slow down for us after 3 seconds
                    double xSafe = currentDistance - minChangeDist - (xEnvelope + (vOther * 15.0));
                    return xSafe > 0 ? true : false;
                }
                else
                    return false;
            }
            else
                return true;
        }
开发者ID:anand-ajmera,项目名称:cornell-urban-challenge,代码行数:37,代码来源:OpposingForwardQuadrantMonitor.cs

示例15: AddBlockage

        /// <summary>
        /// Add blockage to partition
        /// </summary>
        /// <param name="partition"></param>
        /// <param name="c"></param>
        public void AddBlockage(IConnectAreaWaypoints partition, Coordinates c, bool acrossSegment)
        {
            partition.Blockage.BlockageExists = true;
            partition.Blockage.BlockageCoordinates = c;
            partition.Blockage.SecondsSinceObserved = 0.0;
            partition.Blockage.BlockageTimeCost = 1800;

            if (partition.Blockage.BlockageHasExisted)
                partition.Blockage.BlockageLifetime = partition.Blockage.BlockageLifetime * 4.0;

            if (acrossSegment && partition is ArbiterLanePartition)
            {
                foreach (ArbiterLanePartition alp in ((ArbiterLanePartition)partition).NonLaneAdjacentPartitions)
                {
                    if (alp.IsInside(c))
                    {
                        alp.Blockage.BlockageExists = true;
                        alp.Blockage.BlockageCoordinates = c;
                        alp.Blockage.SecondsSinceObserved = 0.0;
                        alp.Blockage.BlockageTimeCost = 1800;

                        if (alp.Blockage.BlockageHasExisted)
                            alp.Blockage.BlockageLifetime = partition.Blockage.BlockageLifetime * 4.0;
                    }
                }
            }

            // reset navigation costs
            this.currentTimes = new KeyValuePair<int, Dictionary<ArbiterWaypointId, DownstreamPointOfInterest>>();
        }
开发者ID:anand-ajmera,项目名称:cornell-urban-challenge,代码行数:35,代码来源:Navigator.cs


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