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


C# Point2D类代码示例

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


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

示例1: DrawLine

 public static Line2D DrawLine(this Factory2D F, Point2D Start, Point2D End)
 {
     Line2D L = F.CreateLine(Start.GetPos(), End.GetPos());
     L.StartPoint = Start;
     L.EndPoint = End;
     return L;
 }
开发者ID:cartman300,项目名称:CatiaNET,代码行数:7,代码来源:FactoryExtensions.cs

示例2: Distance

		/// <summary>
		/// Finds the distance of a specified point from the line segment and the
		/// closest point on the segment to the specified point.
		/// </summary>
		/// <param name="p">The test point.</param>
		/// <param name="closestPt">Closest point on the segment to c.</param>
		/// <returns>Returns the distance from p to the closest point on the segment.</returns>
		public double Distance(Point2D p, Point2D closestPt)
		{
			if (closestPt == null)
				closestPt = new Point2D();

			// Construct vector v (AB) and w (AP)
			var v = new Vector2D(A, B);
			var w = new Vector2D(A, p);

			// Numerator of the component of w onto v. If <= 0 then A
			// is the closest point. By separating into the numerator
			// and denominator of the component we avoid a division unless
			// it is necessary.
			double n = w.Dot(v);
			if (n <= 0.0f)
			{
				closestPt.Set(A);
				return w.Norm();
			}

			// Get the denominator of the component. If the component >= 1
			// (d <= n) then point B is the closest point
			double d = v.Dot(v);
			if (d <= n)
			{
				closestPt.Set(B);
				return new Vector2D(B, p).Norm();
			}

			// Closest point is along the segment. The point is the projection of
			// w onto v.
			closestPt.Set(v.Mult(n / d));
			closestPt.Add(A);
			return new Vector2D(closestPt, p).Norm();
		}
开发者ID:kstenson,项目名称:NHibernate.Search,代码行数:42,代码来源:LineSegment.cs

示例3: Point2D_IsConstructedProperly

        public void Point2D_IsConstructedProperly()
        {
            var result = new Point2D(123.45, 456.78);

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

示例4: DrawLine

    public static void DrawLine(Point2D tFrom, Point2D tTo, Texture2D texture)
    {
        //Debug.Log ("Drawing from: " + tFrom.x + "," + tFrom.y + "  to  " + tTo.x + "," + tTo.y);

        int deltaX = tFrom.x - tTo.x;
        int deltaY = tFrom.y - tTo.y;

        int d = 2*deltaY - deltaX;

        texture.SetPixel(tFrom.x,tFrom.y,Color.black);

        int y = tFrom.y;

        for(int x = tFrom.x + 1; x< tTo.x; x+=1)
        {
            if(d > 0)
            {
                y+=1;
                //Debug.Log (x + " " + y);
                texture.SetPixel(x,y,Color.black);
                d+=(2*deltaY)-(2*deltaX);
            }
            else
            {
                //Debug.Log (x + " " + y);
                texture.SetPixel(x,y,Color.black);
                d+=(2*deltaY);
            }
        }
        texture.Apply();
    }
开发者ID:Fizzly,项目名称:MMesh,代码行数:31,代码来源:RenderUtility.cs

示例5: MahjongDealerIndicator

 public MahjongDealerIndicator(MahjongGame game, Point2D position, MahjongPieceDirection direction, MahjongWind wind)
 {
     this.m_Game = game;
     this.m_Position = position;
     this.m_Direction = direction;
     this.m_Wind = wind;
 }
开发者ID:Crome696,项目名称:ServUO,代码行数:7,代码来源:MahjongDealerIndicator.cs

示例6: ExpandableScroll

 public ExpandableScroll(Control owner, int page, int x, int y, int height)
     : base(0, 0)
 {
     _owner = owner;
     Position = new Point2D(x, y);
     _expandableScrollHeight = height;
 }
开发者ID:Crwth,项目名称:UltimaXNA,代码行数:7,代码来源:ExpandableScroll.cs

示例7: getGazeCoordsToUnityWindowCoords

    /// <summary>
    /// Maps a GazeData gaze point (RawCoordinates or SmoothedCoordinates) to Unity screen space. 
    /// Note that gaze points have origo in top left corner, whilst Unity uses lower left.
    /// </summary>
    /// <param name="gp"/>gaze point to map</param>
    /// <returns>2d point mapped to unity window space</returns>
    public static Point2D getGazeCoordsToUnityWindowCoords(Point2D gp)
    {
        double rx = gp.X * ((double)Screen.width / GazeManager.Instance.ScreenResolutionWidth);
        double ry = (GazeManager.Instance.ScreenResolutionHeight - gp.Y) * ((double)Screen.height / GazeManager.Instance.ScreenResolutionHeight);

        return new Point2D(rx, ry);
    }
开发者ID:arnebp,项目名称:tet-unity-angryeyebots,代码行数:13,代码来源:UnityGazeUtils.cs

示例8: IsPotentialHit

        /// <summary>
        /// Gets a value indicating whether the specified point is potentially a hit for the specified element.
        /// </summary>
        /// <param name="element">The element to evaluate.</param>
        /// <param name="point">The point to evaluate.</param>
        /// <returns><see langword="true"/> if the specified point is a potential hit; otherwise, <see langword="false"/>.</returns>
        public static Boolean IsPotentialHit(UIElement element, Point2D point)
        {
            if (element.Visibility != Visibility.Visible)
                return false;

            if (!element.IsHitTestVisible)
                return false;

            if (!element.VisualBounds.Contains(point))
                return false;

            var clip = element.ClipRectangle;
            if (clip.HasValue)
            {
                var absoluteClip = clip.Value;
                var relativeClip = new RectangleD(
                    absoluteClip.X - element.UntransformedAbsolutePosition.X,
                    absoluteClip.Y - element.UntransformedAbsolutePosition.Y,
                    absoluteClip.Width,
                    absoluteClip.Height);

                if (!relativeClip.Contains(point))
                    return false;
            }

            return true;
        }
开发者ID:RUSshy,项目名称:ultraviolet,代码行数:33,代码来源:HitTestUtil.cs

示例9: CreateScatterPlot

    public ScatterPlot CreateScatterPlot(string variableNameX, string variableNameY, string variableNameColor = "-") {
      ScatterPlot scatterPlot = new ScatterPlot();

      IList<double> xValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameX));
      IList<double> yValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameY));
      if (variableNameColor == null || variableNameColor == "-") {
        List<Point2D<double>> points = new List<Point2D<double>>();

        for (int i = 0; i < xValues.Count; i++) {
          Point2D<double> point = new Point2D<double>(xValues[i], yValues[i]);
          points.Add(point);
        }

        ScatterPlotDataRow scdr = new ScatterPlotDataRow(variableNameX + " - " + variableNameY, "", points);
        scatterPlot.Rows.Add(scdr);

      } else {
        var colorValues = PreprocessingData.GetValues<double>(PreprocessingData.GetColumnIndex(variableNameColor));
        var data = xValues.Zip(yValues, (x, y) => new { x, y }).Zip(colorValues, (v, c) => new { v.x, v.y, c }).ToList();
        var gradients = ColorGradient.Colors;
        int curGradient = 0;
        int numColors = colorValues.Distinct().Count();
        foreach (var colorValue in colorValues.Distinct()) {
          var values = data.Where(x => x.c == colorValue);
          var row = new ScatterPlotDataRow(
            variableNameX + " - " + variableNameY + " (" + colorValue + ")",
            "",
            values.Select(v => new Point2D<double>(v.x, v.y)),
            new ScatterPlotDataRowVisualProperties() { Color = gradients[curGradient] });
          curGradient += gradients.Count / numColors;
          scatterPlot.Rows.Add(row);
        }
      }
      return scatterPlot;
    }
开发者ID:t-h-e,项目名称:HeuristicLab,代码行数:35,代码来源:ScatterPlotContent.cs

示例10: Main

	private static void Main()
	{
		Point p = new Point2D(1, 2);
		IVisitor v = new Chebyshev();
		p.Accept(v);
		Console.WriteLine(p.Metric);
	}
开发者ID:LukinEgor,项目名称:Design-Pattern,代码行数:7,代码来源:Visitor.cs

示例11: Main

 static void Main(string[] args)
 {
     Point2D<int> dot2D = new Point2D<int>(10, 20);
     dot2D.ToString();
     Point3D dot3D = new Point3D(10, 20, 30);
     dot3D.ToString();
 }
开发者ID:makmen,项目名称:itstep-C-,代码行数:7,代码来源:Program.cs

示例12: ContieneElPunto

 public static bool ContieneElPunto(this IEnumerable<Point2D> secuencia, Point2D punto)
 {
     foreach (var puntoEnSecuencia in secuencia)
         if (punto == puntoEnSecuencia)
             return true;
     return false;
 }
开发者ID:digi21,项目名称:UtilidadesDigi,代码行数:7,代码来源:UtilidadesSecuenciaPoint2D.cs

示例13: Add

 public void Add(Point2D[] points)
 {
     foreach (Point2D pt in points)
     {
         Add(pt.X, pt.Y);
     }
 }
开发者ID:oozcitak,项目名称:BoxCulvert,代码行数:7,代码来源:Extents.cs

示例14: IsPointInPolygonTest2

        public void IsPointInPolygonTest2(double x, double y, bool outcome)
        {
            var testPoint = new Point2D(x, y);
            var testPoly = this.TestPolygon4();

            Assert.AreEqual(outcome, Polygon2D.IsPointInPolygon(testPoint, testPoly));
        }
开发者ID:chantsunman,项目名称:mathnet-spatial,代码行数:7,代码来源:Polygon2DTests.cs

示例15: Seek

 /// <summary>
 /// Seek a target in a 2-dimensional grid
 /// </summary>
 /// <param name="grid">The grid to search</param>
 /// <param name="startPoint">The start point to seek from</param>
 /// <param name="targetPoint">The target to seek to</param>
 /// <returns>An array of points in world space needed to pass through to get to the target</returns>
 /// <exception cref="ArgumentOutOfRangeException">
 /// If the start or target are out of range of the grid
 /// </exception>
 public static Point2D[] Seek(GridNode2D[,] grid, Point2D startPoint, Point2D targetPoint)
 {
     return Seek(
         grid, startPoint, targetPoint, true, DEFAULT_MOVEMENTCOST,
         DEFAULT_DIAGONALCOST, DEFAULT_ASCENTCOST, DEFAULT_DESCENTCOST
     );
 }
开发者ID:PurpleKingdomGames,项目名称:CoreLibs,代码行数:17,代码来源:AStar.cs


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