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


C# Plane.RelativePosition方法代码示例

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


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

示例1: Polygon

            /// <summary>
            /// Constructs a new polygon.
            /// </summary>
            /// <remarks>A plane is created using first three vertices.</remarks>
            /// <param name="vertices">A list of vertices that define the outline of the polygon.</param>
            /// <param name="shared">  An identifier of shared properties.</param>
            public Polygon(IList<Vertex> vertices, int shared)
            {
                if (vertices == null || vertices.Count < 3)
                {
                    throw new ArgumentException("Not enough vertices.");
                }
                #if DEBUG
                if (vertices.Count == 3)			// No need to check triangles.
                {
                    // Check if all vertices are on the same plane.
                    List<Vector3> edgeVectors = new List<Vector3>(vertices.Count);
                    for (int i = 1; i < vertices.Count; i++)
                    {
                        edgeVectors.Insert(i - 1, vertices[i].Position - vertices[i - 1].Position);
                    }
                    // Insert last edge.
                    edgeVectors.Add(vertices[0].Position - vertices[vertices.Count - 1].Position);
                    // Check if all edges are coplanar.
                    for (int i = 2; i < edgeVectors.Count; i++)
                    {
                        if (Vector3.Mixed(edgeVectors[i], edgeVectors[i - 1], edgeVectors[i - 2]) > MathHelpers.ZeroTolerance)
                        {
                            throw new ArgumentException("Vertices are not coplanar.");
                        }
                    }
                }
                #endif
                this.Plane = new Plane(vertices[0].Position, vertices[1].Position, vertices[2].Position);
                #if DEBUG
                Plane.PlaneRelativePositionClass position = Plane.PlaneRelativePositionClass.Coplanar;
                // Check if the polygon is convex.
                for (int i = 0; i < vertices.Count; i++)
                {
                    Vector3 previousVertex = vertices[(i == 0) ? vertices.Count - 1 : i - 1].Position;
                    Vector3 currentVertex = vertices[i].Position;
                    Vector3 nextVertex = vertices[(i + 1) % vertices.Count].Position;
                    // Plane formed by edge between previous vertex and current one and a vector
                    // that is parallel to polygon's normal and originates from current vertex.
                    ConstructiveSolidGeometry.Plane planeBefore =
                        new Plane(currentVertex, previousVertex, this.Plane.Normal + currentVertex);

                    position |= planeBefore.RelativePosition(nextVertex);
                    if (position == Plane.PlaneRelativePositionClass.Spanning)
                    {
                        throw new ArgumentException("Given list of vertices does not form a convex polygon.");
                    }
                }
                #endif
                this.Vertices = vertices.ToList();
                this.Shared = shared;
            }
开发者ID:RoqueDeicide,项目名称:CryCIL,代码行数:57,代码来源:ConstructiveSolidGeometry.cs


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