當前位置: 首頁>>代碼示例>>C#>>正文


C# System.Line類代碼示例

本文整理匯總了C#中System.Line的典型用法代碼示例。如果您正苦於以下問題:C# Line類的具體用法?C# Line怎麽用?C# Line使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Line類屬於System命名空間,在下文中一共展示了Line類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Impulse

 public void Impulse(Line force)
 {
     var div = force / Mass;
     var cross = (CenterOfMass - force.Start).Normalize().Dot(div.Normalize());
     DTheta -= div.Length * cross / 3;
     Velocity += div * (1 - cross);
 }
開發者ID:kgroat,項目名稱:AcculturationPhysics,代碼行數:7,代碼來源:PhysicsObject.cs

示例2: OnLoadScene

        public override Scene OnLoadScene()
        {
            this.mEngine.RegisterUpdateHandler(new FPSLogger());

            Scene scene = new Scene(1);
            scene.Background = new ColorBackground(0.09804f, 0.6274f, 0.8784f);

            Random random = new Random(RANDOM_SEED);

            for (int i = 0; i < LINE_COUNT; i++)
            {
                float x1 = (float)(random.NextDouble() * CAMERA_WIDTH);
                float x2 = (float)(random.NextDouble() * CAMERA_WIDTH);
                float y1 = (float)(random.NextDouble() * CAMERA_HEIGHT);
                float y2 = (float)(random.NextDouble() * CAMERA_HEIGHT);
                float lineWidth = (float)(random.NextDouble() * 5);

                Line line = new Line(x1, y1, x2, y2, lineWidth);

                line.SetColor((float)random.NextDouble(), (float)random.NextDouble(), (float)random.NextDouble());

                scene.getLastChild().attachChild(line);
            }

            return scene;
        }
開發者ID:jamesburton,項目名稱:AndEngine.net,代碼行數:26,代碼來源:LineExample.cs

示例3: UpdateDependencies

        public override void UpdateDependencies(double currentTime)
        {
            base.UpdateDependencies(currentTime);

            if (Visible)
            {
                if (_line == null)
                {
                    _line = new Line();
                    _circle = new Circle {Radius = Radius};

                    _circle.AttachTo(this, false);
                    _line.AttachTo(_circle, false);
                    _line.RelativePoint1 = new Point3D(0, 0);
                    _line.RelativePoint2 = new Point3D(Radius, 0);
                }

                if (!_added)
                {
                    ShapeManager.AddLine(_line);
                    ShapeManager.AddCircle(_circle);
                    _added = true;
                }
            }

            if (!Visible && _line != null)
            {
                ShapeManager.Remove(_line);
                ShapeManager.Remove(_circle);
                _added = false;
            }
        }
開發者ID:kainazzzo,項目名稱:flatredball-spriter,代碼行數:32,代碼來源:SpriterPoint.cs

示例4: DelayedHitCalc

 public override RealHitInfo DelayedHitCalc(Line by, HitInfo hit)
 {
     RealHitInfo realHit = new RealHitInfo();
     realHit.HitStuff = Surface;
     realHit.Pigment = Pigment;
     realHit.Normal = new Line();
     realHit.Normal.Start = by.Project(hit.HitDist);
     realHit.Normal.Direct.Dx = 0;
     realHit.Normal.Direct.Dy = 0;
     realHit.Normal.Direct.Dz = 0;
     switch (hit.SurfaceIndex)
     {
         case 0:
             Point hitLoc2 = inv.Apply(realHit.Normal.Start);
             realHit.Normal.Direct.Dx = hitLoc2.X;
             realHit.Normal.Direct.Dy = hitLoc2.Y;
             realHit.Normal.Direct.Dz = hitLoc2.Z;
             break;
         default:
             throw new InvalidOperationException("Invalid surface index in hitdata");
     }
     Vector before = realHit.Normal.Direct;
     realHit.Normal.Direct = trans.Apply(realHit.Normal.Direct);
     if (realHit.Normal.Direct.Dot(by.Direct) > 0)
     {
         realHit.Normal.Direct.ScaleSelf(-1.0);
     }
     return realHit;
 }
開發者ID:Tilps,項目名稱:Stash,代碼行數:29,代碼來源:Sphere.cs

示例5: Add

 /// <summary>
 /// Adds string
 /// </summary>
 /// <param name="format"></param>
 /// <param name="args"></param>
 public void Add( Color color, string format, params object[] args )
 {
     Line line = new Line();
     line.text		= string.Format( format, args );
     line.color		= color;
     linesAccum.Add( line );
 }
開發者ID:temik911,項目名稱:audio,代碼行數:12,代碼來源:DebugStrings.cs

示例6: UpdateDependencies

        public override void UpdateDependencies(double currentTime)
        {
            base.UpdateDependencies(currentTime);

            if (Visible)
            {
                if (_line == null)
                {
                    _line = new Line();
                    _line.AttachTo(this, false);
                    _line.RelativePoint1 = new Point3D(0, 0);
                    _line.RelativePoint2 = new Point3D(Length * ScaleX, 0);
                }

                if (!_added)
                {
                    ShapeManager.AddLine(_line);
                    _added = true;
                }
                if (Math.Abs(_line.RelativePoint2.X - Length * ScaleX) > Double.Epsilon)
                {
                    _line.RelativePoint2.X = Length;
                }
            }

            if (!Visible && _line != null)
            {
                ShapeManager.Remove(_line);
                _added = false;
            }
        }
開發者ID:kainazzzo,項目名稱:flatredball-spriter,代碼行數:31,代碼來源:SpriterBone.cs

示例7: DataAccess_IOrmModelSingleGet

        public void DataAccess_IOrmModelSingleGet()
        {
            Line line = new Line();
            line = (Line)line.Get<Line>(1);

            Assert.AreEqual(line.Title, "Lemongrass and Lavender");
        }
開發者ID:gdirlam,項目名稱:BathProducts,代碼行數:7,代碼來源:Data.cs

示例8: DrawLine

 public void DrawLine (Line line, ConsoleColor? color = null, LineWidth lineWidth = LineWidth.Single)
 {
     if (line.IsHorizontal)
         DrawHorizontalLine(line.X, line.Y, line.Width, color, lineWidth);
     else if (line.IsVertical)
         DrawVerticalLine(line.X, line.Y, line.Height, color, lineWidth);
 }
開發者ID:jhorv,項目名稱:CsConsoleFormat,代碼行數:7,代碼來源:ConsoleBuffer.cs

示例9: DrawableLine

 public DrawableLine()
     : base("DrawableLine", Layer.Opaque)
 {
     line = new Line();
     line.StartColor = Color.Yellow;
     line.EndColor = Color.Yellow;
 }
開發者ID:Kitsune001,項目名稱:Samples,代碼行數:7,代碼來源:DrawableLine.cs

示例10: ExecuteCommand

        public void ExecuteCommand()
        {
            barDiameter = TryGetBarDiameter("\nŚrednica pręta [mm] : ");
            if (!barDiameter.HasValue)
                return;

            spanStep = TryGetSpanStep("\nRozstaw [mm] : ");
            if (!spanStep.HasValue)
                return;

            barPoint1 = TryGetPoint("\nPokaż pręt 1 : ");
            if (!barPoint1.HasValue)
                return;

            barPoint2 = TryGetPoint("\nPokaż pręt 2 : ", barPoint1);
            if (!barPoint2.HasValue)
                return;

            firstBarLine = GetRoundBarLine(roundValue);
            if (TryDisplayBarLadder())
            {
                string blockName = CreateBlockRecord();
                Handle handle = InsertBlock(blockName);
                SetXData(handle);
            }
            else
            {
                return;
            }
        }
開發者ID:anielii,項目名稱:Acommands,代碼行數:30,代碼來源:AContourLines.cs

示例11: GetClosestPoint

 public static bool GetClosestPoint(Line line, Vector3F point, out Vector3F closestPointOnLine)
 {
     float parameter;
       GetLineParameter(new LineSegment(line.PointOnLine, line.PointOnLine + line.Direction), point, out parameter);
       closestPointOnLine = line.PointOnLine + parameter * line.Direction;
       return Vector3F.AreNumericallyEqual(point, closestPointOnLine);
 }
開發者ID:,項目名稱:,代碼行數:7,代碼來源:

示例12: ExplotaAReadOnlyLine

        /// <summary>
        /// Devuelve una secuencia de ReadOnlyLine explotando la entidad si es necesario.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="secuenciaOriginal"></param>
        /// <returns></returns>
        public static IEnumerable<ReadOnlyLine> ExplotaAReadOnlyLine(this Entity entidad)
        {
            if (entidad is ReadOnlyLine)
                yield return entidad as ReadOnlyLine;

            if (entidad is ReadOnlyPolygon)
            {
                ReadOnlyPolygon polígono = entidad as ReadOnlyPolygon;

                // Devolvemos primero el contorno exterior como una línea cerrada
                Line línea = new Line(polígono.Codes);
                línea.Points.Add(polígono.Points);
                yield return línea;

                // Devolvemos cada uno de los huecos que son líneas cerradas
                foreach (var hueco in polígono.Holes)
                    yield return hueco;
            }

            if (entidad is ReadOnlyComplex)
            {
                ReadOnlyComplex complejo = entidad as ReadOnlyComplex;

                foreach (var subentidad in complejo.Entities)
                {
                    if (subentidad is ReadOnlyLine)
                        yield return subentidad as ReadOnlyLine;
                }
            }

            yield break;
        }
開發者ID:digi21,項目名稱:UtilidadesDigi,代碼行數:38,代碼來源:UtilidadesEntity.cs

示例13: LerpProjectOnto

 ///<summary>
 ///The proportion that, when lerped across the given line, results in the given point.
 ///If the point is not on the line segment, the result is the closest point on the extended line.
 ///</summary>
 public static double LerpProjectOnto(this Vector2d point, Line line)
 {
     return line.NearestT(point, false);
     /*var b = point - line[0];
     var d = line.Delta;
     return (b * d) / (d * d);*/
 }
開發者ID:AyyTee,項目名稱:Aventyr,代碼行數:11,代碼來源:GeometryUtil.cs

示例14: GivenAnOrderDiscount_WhenApplyToNonOrder_ThenShouldReturnZero

        public void GivenAnOrderDiscount_WhenApplyToNonOrder_ThenShouldReturnZero()
        {
            var sut = new OrderDiscount("d", 1);
            var line = new Line(new Bike(string.Empty, string.Empty, 1), 1);

            Assert.AreEqual(0, sut.Apply(line));
        }
開發者ID:toddweb,項目名稱:exercises-bike-distributor-refactor,代碼行數:7,代碼來源:OrderDiscountTests.cs

示例15: LineIntersection

        public void LineIntersection()
        {
            Line horizontalLine = new Line(new Vector2D(0.0f, 1.0f), new Vector2D(2.0f, 1.0f));
            Line verticalLine = new Line(new Vector2D(1.0f, 0.0f), new Vector2D(1.0f, 2.0f));

            Assert.IsTrue(horizontalLine.TestIntersection(verticalLine));
            Assert.IsTrue(horizontalLine.TestIntersection(horizontalLine));
            Assert.IsTrue(verticalLine.TestIntersection(verticalLine));

            Line offsetHorizontalLine = new Line(new Vector2D(0.0f, 3.0f), new Vector2D(2.0f, 3.0f));

            Assert.IsFalse(offsetHorizontalLine.TestIntersection(horizontalLine));

            Line reverseHorizontalLine = new Line(new Vector2D(2.0f, 1.0f), new Vector2D(0.0f, 1.0f));
            Line reverseVerticalLine = new Line(new Vector2D(1.0f, 2.0f), new Vector2D(1.0f, 0.0f));
            Line reverseOffsetHorizontalLine = new Line(new Vector2D(0.0f, 3.0f), new Vector2D(2.0f, 3.0f));

            Assert.IsTrue(reverseHorizontalLine.TestIntersection(reverseVerticalLine));
            Assert.IsTrue(reverseHorizontalLine.TestIntersection(verticalLine));
            Assert.IsTrue(reverseVerticalLine.TestIntersection(verticalLine));
            Assert.IsTrue(reverseVerticalLine.TestIntersection(reverseVerticalLine));

            Assert.IsFalse(reverseHorizontalLine.TestIntersection(reverseOffsetHorizontalLine));
            Assert.IsFalse(reverseHorizontalLine.TestIntersection(offsetHorizontalLine));
        }
開發者ID:jesseDtucker,項目名稱:Autonomy,代碼行數:25,代碼來源:LineTests.cs


注:本文中的System.Line類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。