• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# System.Coordinate类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: square_at

        public Square square_at(Coordinate coordinate)
        {
            return contains_token_at(coordinate) ? (Square) 
                new PlayingSquare(_squares[coordinate.X, coordinate.Y]) :
                new EmptyPlayingSquare();

        }
开发者ID:elbandit,项目名称:Tic-Tac-Toe,代码行数:7,代码来源:NineSquareGrid.cs


示例2: Reproject

 public Coordinate Reproject(Coordinate coordinate, ISpatialReference @from, ISpatialReference to)
 {
     double[] xy, z;
     ToDotSpatial(coordinate, out xy, out z);
     DotSpatial.Projections.Reproject.ReprojectPoints(xy, z, GetProjectionInfo(@from), GetProjectionInfo(to), 0, 1);
     return ToGeoAPI(xy, z);
 }
开发者ID:geobabbler,项目名称:SharpMap,代码行数:7,代码来源:DotSpatialReprojector.cs


示例3: Normalize

 /// <summary>
 /// Normalizes the vector <param name="v"></param>
 /// </summary>
 /// <param name="v">The normalized <paramref name="v"/></param>
 public static void Normalize(Coordinate v)
 {
     double absVal = Math.Sqrt(v.X * v.X + v.Y * v.Y + v.Z * v.Z);
     v.X /= absVal;
     v.Y /= absVal;
     v.Z /= absVal;
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:11,代码来源:VectorMath.cs


示例4: IsPointInRing

        /// <summary>
        ///
        /// </summary>
        /// <param name="p"></param>
        /// <param name="ring"></param>
        /// <returns></returns>
        public static bool IsPointInRing(Coordinate p, Coordinate[] ring)
        {
            int i;		    // point index; i1 = i-1 mod n
            int crossings = 0;	// number of edge/ray crossings
            int nPts = ring.Length;

            /* For each line edge l = (i-1, i), see if it crosses ray from test point in positive x direction. */
            for (i = 1; i < nPts; i++)
            {
                int i1 = i - 1;		    // point index; i1 = i-1 mod n
                Coordinate p1 = ring[i];
                Coordinate p2 = ring[i1];
                double x1 = p1.X - p.X;
                double y1 = p1.Y - p.Y;
                double x2 = p2.X - p.X;
                double y2 = p2.Y - p.Y;

                if (((y1 > 0) && (y2 <= 0)) || ((y2 > 0) && (y1 <= 0)))
                {
                    /* e straddles x axis, so compute intersection. */
                    double xInt = (x1 * y2 - x2 * y1) / (y2 - y1);		    // x intersection of e with ray
                    /* crosses ray if strictly positive intersection. */
                    if (0.0 < xInt) crossings++;
                }
            }

            /* p is inside if an odd number of crossings. */
            return (crossings % 2) == 1;
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:35,代码来源:NonRobustCGAlgorithms.cs


示例5: Multipg

        public void Multipg()
        {
            Random rnd = new Random();
            Polygon[] pg = new Polygon[50];
            GeoAPI.Geometries.IPolygon[] pgcheck = new GeoAPI.Geometries.IPolygon[50];
            GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory gf = new GisSharpBlog.NetTopologySuite.Geometries.GeometryFactory();
            for (int i = 0; i < 50; i++)
            {
                Coordinate center = new Coordinate((rnd.NextDouble() * 360) - 180, (rnd.NextDouble() * 180) - 90);
                Coordinate[] coord = new Coordinate[36];
                GeoAPI.Geometries.ICoordinate[] coordscheck = new GeoAPI.Geometries.ICoordinate[36];
                for (int ii = 0; ii < 36; ii++)
                {
                    coord[ii] = new Coordinate(center.X + Math.Cos((ii * 10) * Math.PI / 10), center.Y + (ii * 10) * Math.PI / 10);
                    double x = coord[ii].X;
                    double y = coord[ii].Y;
                    GisSharpBlog.NetTopologySuite.Geometries.Coordinate c = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(x, y);
                    coordscheck[ii] = c;
                }
                coord[35] = new Coordinate(coord[0].X, coord[0].Y);
                coordscheck[35] = new GisSharpBlog.NetTopologySuite.Geometries.Coordinate(coordscheck[0].X, coordscheck[0].Y);
                GeoAPI.Geometries.ILinearRing ring = gf.CreateLinearRing(coordscheck);
                pgcheck[i] = gf.CreatePolygon(ring, null);
                pg[i] = new Polygon(coord);

            }
            MultiPolygon mpg = new MultiPolygon(pg);
            GeoAPI.Geometries.IMultiPolygon mpgcheck = gf.CreateMultiPolygon(pgcheck);
            for (int ii = 0; ii < mpg.Coordinates.Count; ii++)
            {
                Assert.AreEqual(mpg.Coordinates[ii].X, mpgcheck.Coordinates[ii].X);
                Assert.AreEqual(mpg.Coordinates[ii].Y, mpgcheck.Coordinates[ii].Y);
            }
        }
开发者ID:ExRam,项目名称:DotSpatial-PCL,代码行数:34,代码来源:MultiShape.cs


示例6: PointInformation

 private static string PointInformation()
 {
     StringBuilder text = new StringBuilder();
     Window window = Window.GetWindowAtCursor();
     Coordinate pt = new Coordinate(CoordinateType.Absolute, new WindowEntity.Point() { X = Cursor.Position.X, Y = Cursor.Position.Y });
     Color color = Desktop.Primary.GetPixelColor(pt);
     if(window != null)
     {
         WindowEntity.Point rel = pt.ToRelative(window);
         StretchedPoint st = pt.ToStretched(window);
         text.Append("<b>Window</b>: ");
         text.AppendFormat("[{0}, {1}] ", window.Width, window.Height);
         text.AppendFormat("\"{0}\"", window.Title);
         text.AppendLine();
         text.Append("<br><b>Color</b>: ");
         text.AppendLine(color.ToString());
         text.Append("<br><b>Coordinate</b>: Absolute: ");
         text.AppendFormat("X = {0}, Y = {1}", pt.X, pt.Y);
         text.Append("; Relative: ");
         text.AppendFormat("X = {0}, Y = {1}", rel.X, rel.Y);
         text.Append("; Stretched: ");
         text.AppendFormat(CultureInfo.InvariantCulture, "X = {0}, Y = {1}", st.X, st.Y);
     }
     else
     {
         text.Append("<b>Color</b>: ");
         text.AppendLine(color.ToString());
         text.Append("<br><b>Coordinate</b>: Absolute: ");
         text.AppendFormat("{0}, {1}", pt.X, pt.Y);
     }
     return text.ToString();
 }
开发者ID:antgraf,项目名称:BA,代码行数:32,代码来源:HtmlRecorder.cs


示例7: Vector

 /// <summary>
 /// Creates a new instance of a vector where the X, Y and Z terms are the same as the
 /// specified coordinate.
 /// </summary>
 /// <param name="coord">The ICoordinate to use</param>
 public Vector(Coordinate coord)
 {
     X = coord.X;
     Y = coord.Y;
     Z = coord.Z;
     RemoveNan();
 }
开发者ID:DIVEROVIEDO,项目名称:DotSpatial,代码行数:12,代码来源:Vector.cs


示例8: TestWriteZMValuesShapeFile

        private void TestWriteZMValuesShapeFile(bool testM)
        {
            var points = new Coordinate[3];
            points[0] = new Coordinate(0, 0);
            points[1] = new Coordinate(1, 0);
            points[2] = new Coordinate(1, 1);

            var csFactory = DotSpatialAffineCoordinateSequenceFactory.Instance;
            var sequence = csFactory.Create(3, Ordinates.XYZM);
            for (var i = 0; i < 3; i++)
            {
                sequence.SetOrdinate(i, Ordinate.X, points[i].X);
                sequence.SetOrdinate(i, Ordinate.Y, points[i].Y);
                sequence.SetOrdinate(i, Ordinate.Z, 1 + i);
                if (testM)
                    sequence.SetOrdinate(i, Ordinate.M, 11 + i);
            }
            var lineString = Factory.CreateLineString(sequence);

            var attributes = new AttributesTable();
            attributes.AddAttribute("FOO", "Trond");

            var feature = new Feature(Factory.CreateMultiLineString(new[] { lineString }), attributes);
            var features = new Feature[1];
            features[0] = feature;

            var shpWriter = new ShapefileDataWriter("ZMtest", Factory)
            {
                Header = ShapefileDataWriter.GetHeader(features[0], features.Length)
            };
            shpWriter.Write(features);

            // Now let's read the file and verify that we got Z and M back
            var factory = new GeometryFactory(DotSpatialAffineCoordinateSequenceFactory.Instance);

            using (var reader = new ShapefileDataReader("ZMtest", factory))
            {
                reader.Read();
                var geom = reader.Geometry;

                for (var i = 0; i < 3; i++)
                {
                    var c = geom.Coordinates[i];
                    Assert.AreEqual(i + 1, c.Z);
                }

                if (testM)
                {
                    sequence = ((ILineString)geom).CoordinateSequence;
                    for (var i = 0; i < 3; i++)
                    {
                        Assert.AreEqual(sequence.GetOrdinate(i, Ordinate.M), 11 + i);
                    }
                }

                // Run a simple attribute test too
                var v = reader.GetString(0);
                Assert.AreEqual(v, "Trond");
            }
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:60,代码来源:ShapefileWriteTest.cs


示例9: RollForEngagement

        /// <summary>
        /// Finds number of players for each team at a coordinate at rolls to find a winner
        /// 
        /// </summary>
        public void RollForEngagement(Coordinate coordinate, Match match)
        {
            List<Player> homePlayersAtCoordinate = new List<Player>();
            List<Player> awayPlayerAtCoordinate = new List<Player>();

            foreach (Player somePlayer in match.GetPlayersAtCoordinate(coordinate, match))
            {
                if (somePlayer.Team.TeamName == match.HomeTeam.TeamName)
                {
                    homePlayersAtCoordinate.Add(somePlayer);
                }
                else
                {
                    awayPlayerAtCoordinate.Add(somePlayer);
                }
            }

            Console.WriteLine(match.HomeTeam.TeamName + " has " + homePlayersAtCoordinate.Count + " players at coordinate 2,2");
            Console.WriteLine(match.AwayTeam.TeamName + " has " + awayPlayerAtCoordinate.Count + " players at coordinate 2,2");

            //roll for greek players at coordinate
            Random rnd = new Random();

            int rollHome = rnd.Next(1, 7);
            int rollAway = rnd.Next(1, 7);

            Console.WriteLine(match.HomeTeam.TeamName + " rolls " + rollHome);
            Console.WriteLine(match.AwayTeam.TeamName + " rolls " + rollAway);

            //+2 til roll pr. player at coordinate.
            int modifiedGreekRoll = rollHome + homePlayersAtCoordinate.Count * 2;
            int modifiedOlsenRoll = rollAway + awayPlayerAtCoordinate.Count * 2;

            Console.WriteLine("greek modified roll is" + modifiedGreekRoll);
            Console.WriteLine("Olsen modified roll is" + modifiedOlsenRoll);

            ResultOfEngagement engagementResult = FindWinner(match, modifiedGreekRoll, modifiedOlsenRoll);

            var downedPlayer = new Player();
            //add effect (down player, equals half a player next round and can't move.
            if (engagementResult != ResultOfEngagement.Tie)
            {
                downedPlayer = EffectOfEngangement(engagementResult, homePlayersAtCoordinate, awayPlayerAtCoordinate);
            }
            else
            {
                Console.WriteLine("Its was a tie, no player downed");
            }

            if (downedPlayer != null)
            {
                if (match.MatchBall.PlayerWithBall == downedPlayer)
                {
                    //give player to another player at that coordinate
                }
                Console.WriteLine(downedPlayer.Name + " " + downedPlayer.State);
            }

            Console.WriteLine(engagementResult.ToString());
        }
开发者ID:runelippert,项目名称:TestGame,代码行数:64,代码来源:Rolls.cs


示例10: Build

 public Build(BlockTemplate BlockType, Coordinate Location)
     : base(Location)
 {
     this.BlockType = BlockType;
     MarkerTile = TileNames.TaskIconBlank;
     GnomeIcon = TileNames.TaskIconBuild;
 }
开发者ID:Blecki,项目名称:GnomeColony,代码行数:7,代码来源:Build.cs


示例11: Pixel

 public Pixel(Coordinate position, int r, int g, int b)
     : this(position)
 {
     this.R = r;
     this.G = g;
     this.B = b;
 }
开发者ID:rerezz,项目名称:Digitale-Bildbearbeitung,代码行数:7,代码来源:Pixel.cs


示例12: CompareOriented

        /// <summary>
        /// 
        /// </summary>
        /// <param name="pts1"></param>
        /// <param name="orientation1"></param>
        /// <param name="pts2"></param>
        /// <param name="orientation2"></param>
        /// <returns></returns>
        private static int CompareOriented(Coordinate[] pts1, bool orientation1, Coordinate[] pts2, bool orientation2)
        {
            int dir1 = orientation1 ? 1 : -1;
            int dir2 = orientation2 ? 1 : -1;
            int limit1 = orientation1 ? pts1.Length : -1;
            int limit2 = orientation2 ? pts2.Length : -1;

            int i1 = orientation1 ? 0 : pts1.Length - 1;
            int i2 = orientation2 ? 0 : pts2.Length - 1;
            while (true)
            {
                int compPt = pts1[i1].CompareTo(pts2[i2]);
                if (compPt != 0)
                    return compPt;

                i1 += dir1;
                i2 += dir2;
                bool done1 = i1 == limit1;
                bool done2 = i2 == limit2;
                if(done1 && !done2)
                    return -1;
                if(!done1 && done2)
                    return 1;
                if(done1 && done2)
                    return 0;
            }
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:35,代码来源:OrientedCoordinateArray.cs


示例13: Add

 /// <summary>
 /// Adds a point to the current line.
 /// </summary>
 /// <param name="pt">The <see cref="Coordinate" /> to add.</param>
 /// <param name="allowRepeatedPoints">If <c>true</c>, allows the insertions of repeated points.</param>
 public void Add(Coordinate pt, bool allowRepeatedPoints)
 {
     if (_coordList == null)
         _coordList = new CoordinateList();
     _coordList.Add(pt, allowRepeatedPoints);
     _lastPt = pt;
 }
开发者ID:ste10k41,项目名称:nettopologysuite,代码行数:12,代码来源:LinearGeometryBuilder.cs


示例14: is_square_at

 public bool is_square_at(Coordinate coordinate)
 {
     if (coordinate.Y > 2 || coordinate.X > 2)
         return false;
     else
         return true;
 }
开发者ID:elbandit,项目名称:Tic-Tac-Toe,代码行数:7,代码来源:NineSquareGrid.cs


示例15: GPGLL

        /// <summary>
        /// Initializes the NMEA Geographic position, Latitude and Longitude and parses an NMEA sentence
        /// </summary>
        /// <param name="NMEAsentence"></param>
        public GPGLL(string NMEAsentence)
        {
            try
            {
                //Split into an array of strings.
                string[] split = NMEAsentence.Split(new Char[] { ',' });

                try
                {
                    _position = new Coordinate(GPSHandler.GPSToDecimalDegrees(split[3], split[4]),
                                                GPSHandler.GPSToDecimalDegrees(split[1], split[2]));
                }
                catch { _position = null; }

                try
                {
                    _timeOfSolution = new TimeSpan(int.Parse(split[5].Substring(0, 2)),
                                                    int.Parse(split[5].Substring(2, 2)),
                                                    int.Parse(split[5].Substring(4)));
                }
                catch
                {
                    _timeOfSolution = null; // TimeSpan.Zero;
                }
                _dataValid = (split[6] == "A");
            }
            catch { }
        }
开发者ID:siegelpeter,项目名称:UAV-NET,代码行数:32,代码来源:GPGLL.cs


示例16: TundraTile

 public TundraTile(Coordinate position)
 {
     _painter = new TundraTilePainter();
     _name = MainStrings.TundraTileName;
     _properties = new TileProperties(0, 30, position, -20);
     _effects = new TilePropertiesForEffects();
 }
开发者ID:GrigoryanArtem,项目名称:EVO,代码行数:7,代码来源:TundraTile.cs


示例17: CreateFromControlVectors

 /// <summary>
 /// Creates an AffineTransformation defined by a single control vector. A
 /// control vector consists of a source point and a destination point, which is
 /// the image of the source point under the desired transformation. This
 /// produces a translation.
 /// </summary>
 /// <param name="src0">The start point of the control vector</param>
 /// <param name="dest0">The end point of the control vector</param>
 /// <returns>The computed transformation</returns>
 public static AffineTransformation CreateFromControlVectors(Coordinate src0,
         Coordinate dest0)
 {
     double dx = dest0.X - src0.X;
     double dy = dest0.Y - src0.Y;
     return AffineTransformation.TranslationInstance(dx, dy);
 }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:16,代码来源:AffineTransformationFactory.cs


示例18: ComputeEdgeDistance

        /// <summary> 
        /// Computes the "edge distance" of an intersection point p along a segment.
        /// The edge distance is a metric of the point along the edge.
        /// The metric used is a robust and easy to compute metric function.
        /// It is not equivalent to the usual Euclidean metric.
        /// It relies on the fact that either the x or the y ordinates of the
        /// points in the edge are unique, depending on whether the edge is longer in
        /// the horizontal or vertical direction.
        /// NOTE: This function may produce incorrect distances
        /// for inputs where p is not precisely on p1-p2
        /// (E.g. p = (139,9) p1 = (139,10), p2 = (280,1) produces distanct 0.0, which is incorrect.
        /// My hypothesis is that the function is safe to use for points which are the
        /// result of rounding points which lie on the line, but not safe to use for truncated points.
        /// </summary>
        public static double ComputeEdgeDistance(Coordinate p, Coordinate p0, Coordinate p1)
        {
            var dx = Math.Abs(p1.X - p0.X);
            var dy = Math.Abs(p1.Y - p0.Y);

            var dist = -1.0;   // sentinel value
            if (p.Equals(p0)) 
                dist = 0.0;            
            else if (p.Equals(p1)) 
            {
                dist = dx > dy ? dx : dy;
            }
            else 
            {
                double pdx = Math.Abs(p.X - p0.X);
                double pdy = Math.Abs(p.Y - p0.Y);
                dist = dx > dy ? pdx : pdy;

                // <FIX>: hack to ensure that non-endpoints always have a non-zero distance
                if (dist == 0.0 && ! p.Equals2D(p0))                
                    dist = Math.Max(pdx, pdy);
                
            }
            Assert.IsTrue(!(dist == 0.0 && ! p.Equals(p0)), "Bad distance calculation");
            return dist;
        }
开发者ID:Walt-D-Cat,项目名称:NetTopologySuite,代码行数:40,代码来源:LineIntersector.cs


示例19: RandomPoints

 /// <summary>
 /// Creates a specified number of random point features inside a single polygon feature. 
 /// </summary>
 /// <param name="ConstrainingFeature">Random points will be generated inside this polygon feature.</param>
 /// <param name="NumberOfPoints">The number of points to be randomly generated.</param>
 /// <returns>A point feature set with the randomly created features.</returns>
 public static FeatureSet RandomPoints(Feature ConstrainingFeature, int NumberOfPoints)
 {
     //This function generates random points within the boundaries of one polygon feature
     FeatureSet fsOut = new FeatureSet();
     fsOut.FeatureType = FeatureType.Point;
     Coordinate c = new Coordinate();
     Random r = new Random();
     int i = 0;
     while (i < NumberOfPoints)
     {
         c = new Coordinate();
         //make a random point somewhere in the rectangular extents of the feature
         double rndx = r.Next(0, 100000) / 100000.0;
         double rndy = r.Next(0, 100000) / 100000.0;
         c.X = rndx * (ConstrainingFeature.Envelope.Right() - ConstrainingFeature.Envelope.Left()) + ConstrainingFeature.Envelope.Left();
         c.Y = rndy * (ConstrainingFeature.Envelope.Top() - ConstrainingFeature.Envelope.Bottom()) + ConstrainingFeature.Envelope.Bottom();
         //check if the point falls within the polygon featureset
         if (ConstrainingFeature.Intersects(c))
         {
             fsOut.AddFeature(new Feature(c));
             i++;
         }
     }
     return fsOut;
 }
开发者ID:hanchao,项目名称:DotSpatial,代码行数:31,代码来源:RandomGeometry.cs


示例20: PointNotInList

 public static Coordinate PointNotInList(Coordinate[] testPts, Coordinate[] pts)
 {
     foreach (Coordinate testPt in testPts)
         if (!IsInList(testPt, pts))
             return testPt;
     return null;
 }
开发者ID:ste10k41,项目名称:nettopologysuite,代码行数:7,代码来源:EdgeRing.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# System.Currency类代码示例发布时间:2022-05-26
下一篇:
C# System.Coord类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap