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


C# Point.VectorTo方法代码示例

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


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

示例1: DrawDimension

        //////////////////////////////////////////////////////////////////////////////////////////////
        // Draws dimension graphics
        //
        //////////////////////////////////////////////////////////////////////////////////////////////
        DimData DrawDimension(Point point1, Point point2, Point dimText, Vector normal)
        {
            // Compute extension points
            Vector xAxis = point1.VectorTo(point2);

            Vector upVector = normal.CrossProduct(xAxis);
            upVector.Normalize();

            Plane plane = _Tg.CreatePlane(point1, normal);

            Point dimTextProj = AdnInventorUtilities.ProjectOnPlane(dimText, plane);

            double dotP1 = point1.VectorTo(dimTextProj).DotProduct(upVector);
            double dotP2 = point2.VectorTo(dimTextProj).DotProduct(upVector);

            Point extP1 = _Tg.CreatePoint(
                point1.X + upVector.X * dotP1,
                point1.Y + upVector.Y * dotP1,
                point1.Z + upVector.Z * dotP1);

            Point extP2 = _Tg.CreatePoint(
                point2.X + upVector.X * dotP2,
                point2.Y + upVector.Y * dotP2,
                point2.Z + upVector.Z * dotP2);

            double dimValue = extP1.DistanceTo(extP2);

           
            GraphicsNode node = _clientGraphicsMng.CreateNewGraphicsNode();

            LineGraphics extLine1 = _clientGraphicsMng.DrawLine(
                   AdnInventorUtilities.ToArray(point1),
                   AdnInventorUtilities.ToArray(extP1),
                   node);

            LineGraphics extLine2 = _clientGraphicsMng.DrawLine(
                   AdnInventorUtilities.ToArray(point2),
                   AdnInventorUtilities.ToArray(extP2),
                   node);

            LineGraphics dimLine = _clientGraphicsMng.DrawLine(
                  AdnInventorUtilities.ToArray(extP1),
                  AdnInventorUtilities.ToArray(extP2),
                  node);

            extLine1.LineType = LineTypeEnum.kDashedLineType;
            extLine2.LineType = LineTypeEnum.kDashedLineType;

            UnitVector v = extP1.VectorTo(extP2).AsUnitVector();

            double length = 20.0;
            double radius = 7.0;

            Point bottom1 = _Tg.CreatePoint(
                extP1.X + length * v.X,
                extP1.Y + length * v.Y,
                extP1.Z + length * v.Z);

            Point bottom2 = _Tg.CreatePoint(
               extP2.X - length * v.X,
               extP2.Y - length * v.Y,
               extP2.Z - length * v.Z);

            SurfaceBody cone1 = _TBrep.CreateSolidCylinderCone(
                bottom1, extP1,
                radius, radius, 0.0, null);

            SurfaceBody cone2 = _TBrep.CreateSolidCylinderCone(
                bottom2, extP2,
                radius, radius, 0.0, null);

            GraphicsNode dimNode = _clientGraphicsMng.CreateNewGraphicsNode();

            SurfaceGraphics arrow1 = _clientGraphicsMng.DrawSurface(cone1, dimNode);
            SurfaceGraphics arrow2 = _clientGraphicsMng.DrawSurface(cone2, dimNode);

            arrow1.SetTransformBehavior(extP1,
                DisplayTransformBehaviorEnum.kPixelScaling,
                1.0);

            arrow2.SetTransformBehavior(extP2,
               DisplayTransformBehaviorEnum.kPixelScaling,
               1.0);

            
            TextGraphics text = _clientGraphicsMng.DrawText(
                AdnInventorUtilities.GetStringFromAPILength(dimValue),
                false,
                dimNode);

            text.Font = "Arial";
            text.Bold = false;
            text.Italic = false;
            text.FontSize = 20;
            text.PutTextColor(221, 0, 0);
            text.VerticalAlignment = VerticalTextAlignmentEnum.kAlignTextMiddle;
//.........这里部分代码省略.........
开发者ID:derzzle,项目名称:INV2016_TRN,代码行数:101,代码来源:GraphicsDimension.cs


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