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

C# Point2类代码示例

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

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



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

示例1: GetLinePlaneIntersection

        /// <summary>
        /// Determines the intersection between a 2d line and a plane
        /// </summary>
        /// <param name="start">Line start</param>
        /// <param name="end">Line end</param>
        /// <param name="plane">Plane</param>
        /// <returns>Returns intersection details, or null if there was no intersection.</returns>
        public static Line2Intersection GetLinePlaneIntersection( Point2 start, Point2 end, Plane2 plane )
        {
            Vector2 vec = end - start;
            float len = vec.Length;
            vec /= len;

            float startDot = plane.Normal.Dot( start );
            float diffDot = plane.Normal.Dot( vec );

            if ( !Utils.CloseToZero( diffDot ) )
            {
                float t = ( startDot + plane.Distance ) / -diffDot;

                if ( ( t >= 0 ) && ( t <= len ) )
                {
                    Line2Intersection result = new Line2Intersection( );
                    result.IntersectionPosition = start + ( vec * t );
                    result.IntersectionNormal = plane.Normal;
                    result.Distance = t;
                    result.StartInside = ( startDot + plane.Distance ) < 0;
                    return result;
                }
            }

            return null;
        }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:33,代码来源:Intersections2.cs


示例2: Point2_IsConstructedProperly

        public void Point2_IsConstructedProperly()
        {
            var result = new Point2(123, 456);

            TheResultingValue(result)
                .ShouldBe(123, 456);
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:7,代码来源:Point2Tests.cs


示例3: OnRenderOverflowButtonBackground

        protected override void OnRenderOverflowButtonBackground(ToolStripItemRenderEventArgs e)
        {
            Brush triangleBrush = new SolidBrush(Color.Black);
            Point2 itemCenter = new Point2(e.Item.Width / 2, e.Item.Height / 2);
            int triangleSize = 2;

            if (e.Item.Pressed)
            {
                e.Graphics.FillRectangle(
                    new SolidBrush(this.ColorTable.ButtonPressedHighlight),
                    1, 1, e.Item.Width - 2, e.Item.Height - 2);
                e.Graphics.DrawRectangle(
                    new Pen(this.ColorTable.ButtonPressedHighlightBorder),
                    1, 1, e.Item.Width - 3, e.Item.Height - 3);
            }
            else if (e.Item.Selected)
            {
                e.Graphics.FillRectangle(
                    new SolidBrush(this.ColorTable.ButtonSelectedHighlight),
                    1, 1, e.Item.Width - 2, e.Item.Height - 2);
                e.Graphics.DrawRectangle(
                    new Pen(this.ColorTable.ButtonSelectedHighlightBorder),
                    1, 1, e.Item.Width - 3, e.Item.Height - 3);
            }

            e.Graphics.FillPolygon(triangleBrush, new Point[] {
                new Point(itemCenter.X - triangleSize, (e.Item.Height * 3 / 4) - triangleSize),
                new Point(itemCenter.X + triangleSize + 1, (e.Item.Height * 3 / 4) - triangleSize),
                new Point(itemCenter.X, (e.Item.Height * 3 / 4) + (triangleSize / 2))});
        }
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:30,代码来源:DualitorToolStripRenderer.cs


示例4: UpdatePreview

        public override void UpdatePreview()
        {
            ITilemapToolEnvironment env = this.Environment;
            Point2 topLeft = new Point2(
                Math.Min(env.ActionBeginTile.X, env.HoveredTile.X),
                Math.Min(env.ActionBeginTile.Y, env.HoveredTile.Y));
            Point2 size = new Point2(
                1 + Math.Abs(env.ActionBeginTile.X - env.HoveredTile.X),
                1 + Math.Abs(env.ActionBeginTile.Y - env.HoveredTile.Y));

            // Don't update the rect when still using the same boundary size
            bool hoverInsideActiveArea = (env.ActiveOrigin == topLeft && env.ActiveArea.Width == size.X && env.ActiveArea.Height == size.Y);
            if (hoverInsideActiveArea)
                return;

            env.ActiveOrigin = topLeft;
            env.ActiveArea.ResizeClear(size.X, size.Y);
            env.ActiveArea.Fill(true, 0, 0, size.X, size.Y);

            // Manually define outlines in the trivial rect case
            Tileset tileset = env.ActiveTilemap != null ? env.ActiveTilemap.Tileset.Res : null;
            Vector2 tileSize = tileset != null ? tileset.TileSize : Tileset.DefaultTileSize;
            env.ActiveAreaOutlines.Clear();
            env.ActiveAreaOutlines.Add(new Vector2[]
            {
                new Vector2(0, 0),
                new Vector2(tileSize.X * size.X, 0),
                new Vector2(tileSize.X * size.X, tileSize.Y * size.Y),
                new Vector2(0, tileSize.Y * size.Y),
                new Vector2(0, 0) // Close the loop
            });

            env.SubmitActiveAreaChanges(true);
        }
开发者ID:SirePi,项目名称:duality,代码行数:34,代码来源:RectTilemapTool.cs


示例5: New

        public static IViewPort New(VideoTypes videoType, IDisposableResource parent, Point2 location, Size2 size)
        {
            IViewPort api = null;

            #if WIN32
            if (videoType == VideoTypes.D3D9) api = new D3D9.ViewPort(parent, location, size);
            #endif

            #if WIN32 || WINRT || WP8
            if (videoType == VideoTypes.D3D11) api = new D3D11.ViewPort(parent, location, size);
            #endif

            #if WIN32 || OSX || LINUX || iOS || ANDROID || NaCl
            if (videoType == VideoTypes.OpenGL) api = new OpenGL.ViewPort(parent, location, size);
            #endif

            #if XNA
            if (videoType == VideoTypes.XNA) api = new XNA.ViewPort(parent, location, size);
            #endif

            #if VITA
            if (videoType == VideoTypes.Vita) api = new Vita.ViewPort(parent, location, size);
            #endif

            if (api == null) Debug.ThrowError("ViewPortAPI", "Unsuported InputType: " + videoType);
            return api;
        }
开发者ID:reignstudios,项目名称:ReignSDK,代码行数:27,代码来源:ViewPort.cs


示例6: getValidMoves

    public override List<Point2> getValidMoves(Point2 origin, MapProperties mapProperties)
    {
        validPoints.Clear();
        Point2 checkPoint;
        foreach (Point2 dir in legalMoves)
        {
            checkPoint = origin;
            for (int i = 0; i < attackRange; i++)
            {
                checkPoint += dir;
                if (checkPointOutOfBounds(checkPoint))
                {
                    break;
                }
                print(mapProperties);

                Tile tileAtPoint = mapProperties.getTile(checkPoint);
                if (checkTileContainsObstacle(tileAtPoint))
                {
                    break;
                }
                validPoints.Add(checkPoint);
            }
        }
        return validPoints;
    }
开发者ID:OutOfHandGames,项目名称:PROMNight,代码行数:26,代码来源:AttackAction.cs


示例7: TilemapTileDrawSource

 public TilemapTileDrawSource(Tilemap tilemap, Point2 origin, Grid<bool> area)
 {
     if (tilemap == null) throw new ArgumentNullException("tilemap");
     this.tilemap = tilemap;
     this.origin = origin;
     this.area = new Grid<bool>(area);
 }
开发者ID:SirePi,项目名称:duality,代码行数:7,代码来源:TilemapTileDrawSource.cs


示例8: getValidMoves

 public override List<Point2> getValidMoves(Point2 origin, MapProperties mapProperties)
 {
     validPoints.Clear();
     foreach (Point2 dir in legalMoves)
     {
         Point2 checkPoint = origin + dir;
         if (!checkPointOutOfBounds(checkPoint))
         {
             Tile tileAtPoint = mapProperties.getTile(checkPoint);
             if (checkTileNeutral(tileAtPoint))
             {
                 validPoints.Add(checkPoint);
             }
             else
             {
                 while (checkTileOwned(tileAtPoint) && !checkTileContainsEntity(tileAtPoint))
                 {
                     validPoints.Add(checkPoint);
                     checkPoint += dir;
                     if (checkPointOutOfBounds(checkPoint))
                     {
                         break;
                     }
                     tileAtPoint = mapProperties.getTile(checkPoint);
                 }
             }
         }
     }
     return validPoints;
 }
开发者ID:OutOfHandGames,项目名称:PROMNight,代码行数:30,代码来源:MoveAction.cs


示例9: getAffectedTiles

 public override List<Point2> getAffectedTiles(Point2 origin, Point2 affectedTile, MapProperties mapProperties)
 {
     List<Point2> affectedTiles = new List<Point2>();
     affectedTiles.Add(origin);
     affectedTiles.Add(affectedTile);
     return affectedTiles;
 }
开发者ID:OutOfHandGames,项目名称:PROMNight,代码行数:7,代码来源:MoveAction.cs


示例10: epsg3140_to_wgs

        public void epsg3140_to_wgs()
        {
            var crs = EpsgMicroDatabase.Default.GetCrs(3140);
            var wgs = EpsgMicroDatabase.Default.GetCrs(4326);

            // source for coordinates is http://epsg.io/3140/map
            var ptWgs = new GeographicCoordinate(-17.785, 177.97);
            var pt3140 = new Point2(530138.52663372, 821498.68898981); // units in links

            var gen = new EpsgCrsCoordinateOperationPathGenerator();
            var paths = gen.Generate(wgs, crs);
            var compiler = new StaticCoordinateOperationCompiler();
            var txs = paths
                .Select(p => compiler.Compile(p))
                .Where(p => p != null);

            var forward = txs.Single();
            var actualForward = (Point2)forward.TransformValue(ptWgs);
            Assert.AreEqual(pt3140.X, actualForward.X, 30);
            Assert.AreEqual(pt3140.Y, actualForward.Y, 30);

            var reverse = forward.GetInverse();
            var actualReverse = (GeographicCoordinate)reverse.TransformValue(pt3140);
            Assert.AreEqual(ptWgs.Longitude, actualReverse.Longitude, 0.01);
            Assert.AreEqual(ptWgs.Latitude, actualReverse.Latitude, 0.01);
        }
开发者ID:aarondandy,项目名称:pigeoid,代码行数:26,代码来源:EpsgCoordOperationRegressionTests.cs


示例11: Line2Intersection

 /// <summary>
 /// Setup constructor
 /// </summary>
 /// <param name="pos"> Ray intersection position </param>
 /// <param name="normal"> Ray intersection normal </param>
 /// <param name="distance"> Ray intersection distance </param>
 /// <param name="obj">Intersected object</param>
 public Line2Intersection( Point2 pos, Vector2 normal, float distance, object obj )
 {
     m_Position	= pos;
     m_Normal	= normal;
     m_Distance	= distance;
     m_Object	= obj;
 }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:14,代码来源:Line2Intersection.cs


示例12: Main

        static void Main(string[] args)
        {
            /********* VALUE TYPES *********/
            int x = 5;

            ChangeValue(x); //only set to 10 in this method, one method completes program will go back to using x value in the main arguments scope. This application will print out x being equal to 5.

            Console.WriteLine("X: {0}", x);

            /********* REFERENCE TYPES *********/

            Point1 p1 = new Point1(); //reference types are usually classes and arrays
            p1.X = 5;
            p1.Y = 10;

            Point1 p2 = p1;
            Point1 p3 = p2;

            p3.Y = 50;

            Console.WriteLine(p2.Y);

            Point2 p10 = new Point2();
            p10.X = 10;
            p10.Y = 5;

            ChangePoint(p10);

            Console.WriteLine("X: {0}, Y:{1}", p10.X, p10.Y);

            Console.ReadLine();
        }
开发者ID:andrewrgoss,项目名称:udemy-beginning-csharp,代码行数:32,代码来源:Program.cs


示例13: Rectangle2

 public Rectangle2(Point2 point, Size2 sizeF)
 {
     X = point.X;
     Y = point.Y;
     Width = sizeF.Width;
     Height = sizeF.Height;
 }
开发者ID:JurgenCox,项目名称:compbio-base,代码行数:7,代码来源:Rectangle2.cs


示例14: SearchNode

 /// <summary>
 /// Create new Search Node.
 /// </summary>
 /// <param name="_position">Position of the Search Node in the grid.</param>
 /// <param name="_cost">Cost to move to this Node.</param>
 /// <param name="_pathCost">Estimated cost of the path.</param>
 /// <param name="_next">Next Search Node.</param>
 public SearchNode(Point2 _position, int _cost, int _pathCost, SearchNode _next)
 {
     this.position = _position;
     this.cost = _cost;
     this.pathCost = _pathCost;
     this.next = _next;
 }
开发者ID:SlowSeer,项目名称:HexTest,代码行数:14,代码来源:SearchNode.cs


示例15: distanceSquaredFrom

        public int distanceSquaredFrom(Point2 to)
        {
            int deltaX = to.X - m_position.X;
            int deltaY = to.Y - m_position.Y;

            return deltaX * deltaX + deltaY * deltaY;
        }
开发者ID:RandomTiger,项目名称:OgresLairVR,代码行数:7,代码来源:Entity.cs


示例16: Rectangle

 public Rectangle( Point2 min, Point2 max )
 {
     m_X = min.X;
     m_Y = min.Y;
     m_Width = max.X - min.X;
     m_Height = max.Y - min.Y;
 }
开发者ID:johann-gambolputty,项目名称:robotbastards,代码行数:7,代码来源:Rectangle.cs


示例17: KrovakModifiedNorth

 public KrovakModifiedNorth(
     GeographicCoordinate geographicOrigin,
     double latitudeOfPseudoStandardParallel,
     double azimuthOfInitialLine,
     double scaleFactor,
     Vector2 falseProjectedOffset,
     ISpheroid<double> spheroid,
     Point2 evaluationPoint,
     double[] constants
 )
     : this(new KrovakModified(
     geographicOrigin,
     latitudeOfPseudoStandardParallel,
     azimuthOfInitialLine,
     scaleFactor,
     falseProjectedOffset,
     spheroid,
     evaluationPoint,
     constants
 ))
 {
     Contract.Requires(spheroid != null);
     Contract.Requires(constants != null);
     Contract.Requires(constants.Length == 10);
 }
开发者ID:aarondandy,项目名称:pigeoid,代码行数:25,代码来源:KrovakModifiedNorth.cs


示例18: cast_vector

        public void cast_vector() {
            var ptA = new Point2(2, 3);

            Vector2 vecA = ptA;
            Point2 ptB = vecA;

            ptB.Should().Be(ptA);
        }
开发者ID:aarondandy,项目名称:vertesaur,代码行数:8,代码来源:Point2Facts.cs


示例19: coordinate_pair_get_elements

        public void coordinate_pair_get_elements() {
            ICoordinatePair<double> p = new Point2(3, 4);

            var a = new Vector2(p);

            Assert.Equal(3, a.X);
            Assert.Equal(4, a.Y);
        }
开发者ID:aarondandy,项目名称:vertesaur,代码行数:8,代码来源:Vector2Facts.cs


示例20: interface_point_extraction

        public static void interface_point_extraction() {
            var p = new Point2(1, 2);
            var line = new Line2(p, new Vector2(3, 4));

            var explicitP = ((ILine2<double>)line).P;

            explicitP.Should().Be(p);
        }
开发者ID:aarondandy,项目名称:vertesaur,代码行数:8,代码来源:Line2Facts.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# Point2D类代码示例发布时间:2022-05-24
下一篇:
C# Point类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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