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


C# LineSegment类代码示例

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


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

示例1: CircleIntersectSegment

 public static bool CircleIntersectSegment(LineSegment<Vector2> segment, Circle circle, out Vector2 intersection)
 {
     intersection = ClosestPointOnSegment(segment, circle.Position);
     var distance2 = DistanceSquared(intersection, circle.Position);
     if (distance2 <= circle.Radius * circle.Radius) return true;
     else return false;
 }
开发者ID:det,项目名称:Rimbalzo,代码行数:7,代码来源:Trig.cs

示例2: CollidesWith

        public bool CollidesWith(LineSegment lineSegment)
        {
            var axisA = new Line(Point1, Point2.Substract(Point1));

            if (axisA.OnOneSide(lineSegment))
            {
                return false;
            }

            var axisB = new Line(lineSegment.Point1, lineSegment.Point2.Substract(lineSegment.Point1));

            if (axisB.OnOneSide(this))
            {
                return false;
            }

            if (axisA.Direction.IsParallel(axisB.Direction))
            {
                Range rangeA = ProjectOnto(axisA.Direction);
                Range rangeB = lineSegment.ProjectOnto(axisA.Direction);

                return rangeA.Overlaps(rangeB);
            }

            return true;
        }
开发者ID:gmoller,项目名称:SpaceDefender,代码行数:26,代码来源:LineSegment.cs

示例3: ProjectOnto

		public static Point ProjectOnto(this Point p, LineSegment seg, LineType type, out int? end)
		{
			end = 0;
			Vector v = seg.Vector();
			Vector w = p.Sub(seg.A);
			T c1 = w.Dot(v); // c1 == |w|*|v|*cos(angle between them)
			if (c1 <= 0) { // angle between line segment and (p-seg.A) is negative (-180..0)?
				if (v.X == 0 && v.Y == 0) {
					// seg.A == seg.B
					end = null;
					return seg.A;
				} else if (c1 < 0)
					end = -1;
				if (type != LineType.Infinite)
					return seg.A;
			}
			T c2 = v.Quadrance(); // == |v|*|v|
			if (c1 >= c2) { // quadrance from seg.A to projected point >= quadrance of seg
				if (c1 > c2)
					end = 1;
				if (type == LineType.Segment)
					return seg.B;
			}
			if (c2 == 0) {
				// seg.A and seg.B are infitessimally close together; c2 was truncated to zero
				end = null;
				return seg.A;
			}

			T frac = c1 / c2;                    // == |w|/|v|*cos(angle)
			Point projected = seg.A.Add(v.Mul(frac)); // == p0 + v/|v|*|w|*cos(angle)
			return projected;
		}
开发者ID:qwertie,项目名称:ecsharp,代码行数:33,代码来源:LineMathTT.cs

示例4: Test_SetLineLength

        public void Test_SetLineLength()
        {
            var line = new LineSegment ();
            line.Length = 2;

            Assert.AreEqual (2.0f, line.Length);
        }
开发者ID:weimingtom,项目名称:erica,代码行数:7,代码来源:TestLineSegment.cs

示例5: CheckPaths

    public void CheckPaths(LineSegment line, Vector3 slot)
    {
        var p1 = line.p1 * divisions;
        var p2 = line.p2 * divisions;
        var th = 0.01f;
        th += 0.5f;
        if (p1.x == p2.x && p1.z != p2.z && p1.y == p2.y) // travels along z, stationary in x and y
        {
            var line2d = new Vector2(p1.x, p1.y);
            var slot2d = new Vector2(slot.x, slot.y);
            if (Vector2.Distance(line2d, slot2d) <= th)
            {
                if (p1.z < p2.z && p1.z <= slot.z - th && p2.z >= slot.z + th)
                    MakeNew(slot, line);
            }
        }

        else if (p1.z == p2.z && p1.x != p2.x && p1.y == p2.y) // travels along x, stationary in z and y
        {
            var line2d = new Vector2(p1.y, p1.z);
            var slot2d = new Vector2(slot.y, slot.z);
            if (Vector2.Distance(line2d, slot2d) <= th)
                if (p1.x < p2.x && p1.x <= slot.x - th && p2.x >= slot.x + th)
                    MakeNew(slot, line);
        }
    }
开发者ID:drt-ftl,项目名称:VAME,代码行数:26,代码来源:PathVoxelizer.cs

示例6: SetPlayShape

	private void SetPlayShape()
	{
		play.Children.Clear ();

		Path p = new Path();
		PathGeometry geometry = new PathGeometry ();
		PathFigure f = new PathFigure ();	
		f.Segments = new PathSegmentCollection ();

		p.Data = geometry;
		p.Fill = new SolidColorBrush(Colors.Red);
		p.Stroke = new SolidColorBrush(Colors.Black);
		geometry.Figures = new PathFigureCollection ();
		geometry.Figures.Add(f);

		LineSegment m = new LineSegment();
		m.Point = new Point(3, 2);
		f.Segments.Add(m);

		m = new LineSegment();	
		m.Point = new Point(14, 8.5);
		f.Segments.Add(m);

		m = new LineSegment();	
		m.Point = new Point(3, 15);
		f.Segments.Add(m);

		m = new LineSegment();	
		m.Point = new Point(3, 2);
		f.Segments.Add(m);

		play.Children.Add(p);
	}
开发者ID:dfr0,项目名称:moon,代码行数:33,代码来源:video-player.cs

示例7: ScanVoxels

 public void ScanVoxels(LineSegment line, bool movesInX)
 {
     var divisions = cSectionGCD.sloxelResolution.x;
     var half = 0.5f / divisions;
     foreach (var v in cSectionGCD.voxels)
     {
         if (movesInX)
         {
             var x = v.Key.x;
             var v2d = new Vector2(v.Key.y, v.Key.z);
             var l2d = new Vector2(line.p1.y, line.p1.z);
             if (Mathf.Abs(v.Key.y - line.p1.y) <= half && Mathf.Abs(v.Key.z - line.p1.z) <= half)
             {
                 if (line.p2.x > line.p1.x && line.p1.x < x + half && line.p2.x > x - half) // p2 greater than p1, p1 < x + half,  p2 > x - half
                     MakeNew(v.Value, line);
                 else if (line.p2.x < line.p1.x && line.p1.x > x - half && line.p2.x < x + half)
                     MakeNew(v.Value, line);
             }
         }
         else // Moves In Z
         {
             var z = v.Key.z;
             var v2 = new Vector2(v.Key.x, v.Key.y);
             var l2 = new Vector2(line.p1.x, line.p1.y);
             if (Mathf.Abs(v.Key.x - line.p1.x) <= half && Mathf.Abs(v.Key.y - line.p1.y) <= half)
             {
                 if (line.p2.z > line.p1.z && line.p1.z < z + half && line.p2.z > z - half) // p2 greater than p1, p1 < x + half,  p2 > x - half
                     MakeNew(v.Value, line);
                 else if (line.p2.z < line.p1.z && line.p1.z > z - half && line.p2.z < z + half)
                     MakeNew(v.Value, line);
             }
         }
     }
 }
开发者ID:drt-ftl,项目名称:VAME,代码行数:34,代码来源:PathFitter.cs

示例8: Test_SetLineWidth

        public void Test_SetLineWidth()
        {
            var line = new LineSegment ();
            line.Width = 2.0f;

            Assert.AreEqual (2.0f, line.Width);
        }
开发者ID:weimingtom,项目名称:erica,代码行数:7,代码来源:TestLineSegment.cs

示例9: CreatePolylineX

        // Creates a polyline with two paths in the shape of an 'X' centered at the given point
        private Polyline CreatePolylineX(MapPoint center, double length)
        {
            var halfLen = length / 2.0;

			LineSegment segment = new LineSegment(
				new MapPoint(center.X - halfLen, center.Y + halfLen, MyMapView.SpatialReference),
				new MapPoint(center.X + halfLen, center.Y - halfLen, MyMapView.SpatialReference));

			LineSegment segment2 = new LineSegment(
				new MapPoint(center.X + halfLen, center.Y + halfLen, MyMapView.SpatialReference),
				new MapPoint(center.X - halfLen, center.Y - halfLen, MyMapView.SpatialReference));

			var segmentCollection = new SegmentCollection(MyMapView.SpatialReference)
			{
				segment
			};

			var segmentCollection2 = new SegmentCollection(MyMapView.SpatialReference)
			{
				segment2
			};

			return new Polyline(new [] { segmentCollection, segmentCollection2},
				MyMapView.SpatialReference);
        }
开发者ID:jordanparfitt,项目名称:arcgis-runtime-samples-dotnet,代码行数:26,代码来源:CreatePolylines.xaml.cs

示例10: PathStatistics

 public PathStatistics(PathData data)
 {
     _data = data;
     int i = 1;
     _totalLength = 0;
     ISegment newSegment;
     while (i < _data.Points.Length)
     {
         switch (_data.Types[i])
         {
             case 1:
                 newSegment = new LineSegment(_data.Points[i - 1], _data.Points[i]);
                 i++;
                 break;
             case 3:
                 newSegment = new CubicBezierSegment(_data.Points[i - 1], _data.Points[i], _data.Points[i + 1], _data.Points[i + 2]);
                 i+= 3;
                 break;
             default:
                 throw new NotSupportedException();
         }
         newSegment.StartOffset = _totalLength;
         _segments.Add(newSegment);
         _totalLength += newSegment.Length;
     }
 }
开发者ID:dteunkenstt,项目名称:SVG,代码行数:26,代码来源:PathStatistics.cs

示例11: LLShape

		public LLMarkerRotated LLShape(DrawStyle style, ref LineSegment<Coord> toArrow)
		{
			Coord frac = Width * Scale / toArrow.Length();
			var markerPoint = toArrow.PointAlong(1 - frac * 0.5f);
			toArrow = toArrow.A.To(toArrow.PointAlong(1 - Math.Min(frac, 1)));
			return new LLMarkerRotated(style, markerPoint, Scale, Geometry, (Coord)toArrow.Vector().AngleDeg());
		}
开发者ID:Shaykh,项目名称:Loyc,代码行数:7,代码来源:LineOrArrow.cs

示例12: LineSegmentOnPlane

 /// <summary>
 /// Projects the specified line segment on the specified plane.
 /// </summary>
 /// <param name="lineSegment">A line segment.</param>
 /// <param name="plane">A plane.</param>
 /// <returns>The <paramref name="lineSegment"/> projected on the <paramref name="plane"/>.</returns>
 public static LineSegment LineSegmentOnPlane(LineSegment lineSegment, Plane plane)
 {
     return new LineSegment
     {
         End1 = Project.PointOnPlane(lineSegment.End1, plane),
         End2 = Project.PointOnPlane(lineSegment.End2, plane),
     };
 }
开发者ID:atulloh,项目名称:IMML,代码行数:14,代码来源:Project.cs

示例13: LineSegmentOnLineSegment

 /// <summary>
 /// Projects the specified line segment on the specified line segment.
 /// </summary>
 /// <param name="lineSegment1">A line segment.</param>
 /// <param name="lineSegment2">A line segment.</param>
 /// <returns>The <paramref name="lineSegment1"/> projected on the <paramref name="lineSegment2"/>.</returns>
 public static LineSegment LineSegmentOnLineSegment(LineSegment lineSegment1, LineSegment lineSegment2)
 {
     return new LineSegment
     {
         End1 = Project.PointOnLineSegment(lineSegment1.End1, lineSegment2),
         End2 = Project.PointOnLineSegment(lineSegment1.End2, lineSegment2),
     };
 }
开发者ID:atulloh,项目名称:IMML,代码行数:14,代码来源:Project.cs

示例14: LineSegmentOnLine

 /// <summary>
 /// Projects the specified line segment on the specified line.
 /// </summary>
 /// <param name="lineSegment">A line segment.</param>
 /// <param name="line">A line.</param>
 /// <returns>The <paramref name="lineSegment"/> projected on the <paramref name="line"/>.</returns>
 public static LineSegment LineSegmentOnLine(LineSegment lineSegment, Line line)
 {
     return new LineSegment
     {
         End1 = Project.PointOnLine(lineSegment.End1, line),
         End2 = Project.PointOnLine(lineSegment.End2, line),
     };
 }
开发者ID:atulloh,项目名称:IMML,代码行数:14,代码来源:Project.cs

示例15: Test_SetTexture

        public void Test_SetTexture()
        {
            var line = new LineSegment ();
            var tex = new Texture("abstract7.png");

            line.Texture = tex;
            Assert.AreEqual (tex, line.Texture);
        }
开发者ID:weimingtom,项目名称:erica,代码行数:8,代码来源:TestLineSegment.cs


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