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


C# Line.IsTangentTo方法代码示例

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


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

示例1: SquareAroundCircle

        public void SquareAroundCircle()
        {
            var circle = new Circle() { center = new Point(0, 0, false), rad = new Parameter(10, false) };

            // We want a box around the circle where all lines touch the 
            // circle and line0 is vertical. We arrange the lines roughly
            // in the correct placement to get the search off to a good
            // start
            var line0 = new Line(new Point(-21,0), new Point(0, 23));
            var line1 = new Line(new Point(0,22), new Point(22, 0));
            var line2 = new Line(new Point(21,0), new Point(0, -29));
            var line3 = new Line(new Point(0,-27), new Point(-25, 0));

            var angle = new Parameter (Math.PI/2, false);

            var r = SketchSolve.Solver.solve
                ( true
                , line0.IsTangentTo(circle)
                , line1.IsTangentTo(circle)
                , line2.IsTangentTo(circle)
                , line3.IsTangentTo(circle)
                , line0.HasInternalAngle (line1, angle)
                , line1.HasInternalAngle(line2, angle) 
                , line2.HasInternalAngle(line3, angle)
                , line3.HasInternalAngle(line0, angle)
                , line0.p2.IsColocated(line1.p1)
                , line1.p2.IsColocated(line2.p1)
                , line2.p2.IsColocated(line3.p1)
                , line3.p2.IsColocated(line0.p1)
                , line0.IsVertical()
                //, line1.IsHorizontal()
                //, line2.IsVertical()
                //, line3.IsHorizontal()
                );

            Console.WriteLine (line0);
            Console.WriteLine (line1);
            Console.WriteLine (line2);
            Console.WriteLine (line3);

            Console.WriteLine (circle.CenterTo(line0));

            r.Should ().BeApproximately (0, 0.0001);


        }       
开发者ID:bradphelan,项目名称:SketchSolve.NET,代码行数:46,代码来源:Test.cs

示例2: TangentToCircleConstraintWithLineInitiallyThroughCenter

        public void TangentToCircleConstraintWithLineInitiallyThroughCenter()
        {
            // Create a fully constrained circle at 0,0 with radius 1
            var circle = new Circle() { center = new Point(0, 0, false), rad = new Parameter(1, false) };

            var v = 1 / Math.Sin(Math.PI / 4);

            var line = new Line(new Point(0, -v, false, false), new Point(0, v, true, false));

            var r = SketchSolve.Solver.solve
                ( true
                , line.IsTangentTo(circle));

            Console.WriteLine (line);
            r.Should().BeApproximately(0,0.0001);

            (circle.CenterTo (line).Vector.LengthSquared - 1).Should ().BeApproximately (0, 0.001);
        }
开发者ID:bradphelan,项目名称:SketchSolve.NET,代码行数:18,代码来源:Test.cs

示例3: TangentToCircleConstraintWithLineInitiallyHorizontalShouldWork

        public void TangentToCircleConstraintWithLineInitiallyHorizontalShouldWork()
        {
            // Create a fully constrained circle at 0,0 with radius 1
            var circle = new Circle() { center = new Point(0, 0, false), rad = new Parameter(10, false) };

            var v = -15;

            var line = new Line(new Point(-100, -v, false, true), new Point(100, -v*2.1, false, true));

            var r = SketchSolve.Solver.solve
                ( true
                , line.IsTangentTo(circle)
                , line.IsHorizontal()
                );

            Console.WriteLine (line);
            Console.WriteLine (circle);

            (circle.CenterTo (line).Vector.LengthSquared - circle.rad.Value*circle.rad.Value)
                .Should ()
                .BeApproximately (0, 0.001);
        }
开发者ID:bradphelan,项目名称:SketchSolve.NET,代码行数:22,代码来源:Test.cs

示例4: TangentToCircleConstraintShouldWork

        public void TangentToCircleConstraintShouldWork()
        {
            // Create a fully constrained circle at 0,0 with radius 1
            var circle = new Circle() { center = new Point(0, 0, false), rad = new Parameter(1, false) };

            var v = 1 / Math.Sin(Math.PI / 4);

            var line = new Line(new Point(0, -v, false, false), new Point(35, 0, true, false));

            var r = SketchSolve.Solver.solve
                ( true
                , line.IsTangentTo(circle));

            r.Should().BeApproximately(0,0.0001);

            line.p2.x.Value.Should().BeApproximately(v, 0.001);

            
        }
开发者ID:bradphelan,项目名称:SketchSolve.NET,代码行数:19,代码来源:Test.cs


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