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


C# Vector3d.length方法代码示例

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


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

示例1: Line

        //----------------------------------CONSTRUCTORS---------------------------------//
        /**
         * Constructor for a line. The line created is the intersection between two planes
         *
         * @param face1 face representing one of the planes
         * @param face2 face representing one of the planes
         */
        public Line(Face face1, Face face2)
        {
            Vector3d normalFace1 = face1.getNormal();
            Vector3d normalFace2 = face2.getNormal();

            //direction: cross product of the faces normals
            direction = new Vector3d();
            direction.cross(normalFace1, normalFace2);

            //if direction lenght is not zero (the planes aren't parallel )...
            if (!(direction.length() < TOL))
            {
                //getting a line point, zero is set to a coordinate whose direction
                //component isn't zero (line intersecting its origin plan)
                point = new Point3d();
                double d1 = -(normalFace1.x * face1.v1.x + normalFace1.y * face1.v1.y + normalFace1.z * face1.v1.z);
                double d2 = -(normalFace2.x * face2.v1.x + normalFace2.y * face2.v1.y + normalFace2.z * face2.v1.z);
                if (Math.Abs(direction.x) > TOL)
                {
                    point.x = 0;
                    point.y = (d2 * normalFace1.z - d1 * normalFace2.z) / direction.x;
                    point.z = (d1 * normalFace2.y - d2 * normalFace1.y) / direction.x;
                }
                else if (Math.Abs(direction.y) > TOL)
                {
                    point.x = (d1 * normalFace2.z - d2 * normalFace1.z) / direction.y;
                    point.y = 0;
                    point.z = (d2 * normalFace1.x - d1 * normalFace2.x) / direction.y;
                }
                else
                {
                    point.x = (d2 * normalFace1.y - d1 * normalFace2.y) / direction.z;
                    point.y = (d1 * normalFace2.x - d2 * normalFace1.x) / direction.z;
                    point.z = 0;
                }
            }

            direction.normalize();
        }
开发者ID:dlannan,项目名称:csg-toolkit,代码行数:46,代码来源:Line.cs


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