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


C# Plane.ClosestPoint方法代码示例

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


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

示例1: ClosestPointOnPlane

        public void ClosestPointOnPlane()
        {
            Plane p = new Plane(new Vector3(0, 0.5f, 0.8660254f), new Vector3(0.75f, 0.5f, -0.4330128f), new Vector3(-0.75f, 0.5f, -0.4330126f));

            //Point below plane
            AssertT.AreEqual(new Vector3(0, 0.5f, 0), p.ClosestPoint(new Vector3(0, 0, 0)));

            //Point above plane
            AssertT.AreEqual(new Vector3(0, 0.5f, 0), p.ClosestPoint(new Vector3(0, 1, 0)));
        }
开发者ID:ylyking,项目名称:Myre,代码行数:10,代码来源:PlaneExtensionsTest.cs

示例2: SolveInstance

        protected override void SolveInstance(IGH_DataAccess DA)
        {
            // --- Input

            var mesh = default(Mesh);
            var planes = new List<Plane>();
            var thickness = default(double);
            var deeper = default(double);

            DA.GetData(0, ref mesh);
            DA.GetDataList(1, planes);
            DA.GetData(2, ref thickness);
            DA.GetData(3, ref deeper);


            // --- Execute

            var tolerance = DocumentTolerance();

            var slitPlanes = new SlitPlane[planes.Count];

            for (int i = 0; i < planes.Count; i++)
                slitPlanes[i] = new SlitPlane(mesh, planes[i], tolerance);

            var bbox = mesh.GetBoundingBox(false);
            var dmax = bbox.Diagonal.Length;
                      
            for (int i = 0; i < planes.Count; i++)
            {
                for (int j = i + 1; j < planes.Count; j++)
                {
                    var a = planes[i];
                    var b = planes[j];

                    var origin = default(Vector3d);
                    var direction = default(Vector3d);

                    if (a.Normal.IsParallelTo(b.Normal) != 0)
                        continue;

                    IntersectPlanes(a, b, out origin, out direction);

                    var cPlane = new Plane(bbox.Center, direction);
                    origin = (Vector3d)cPlane.ClosestPoint((Point3d)origin);                    

                    var originA = origin.Map2D(a);
                    var directionA = direction.Map2D(a);

                    var originB = origin.Map2D(b);
                    var directionB = direction.Map2D(b);

                    var line = new LineCurve((Point3d)(origin - dmax * direction), ((Point3d)origin + dmax * direction));

                    var alpha = Vector3d.VectorAngle(a.Normal, b.Normal);
                    var t = thickness * Math.Tan(alpha / 2);

                    slitPlanes[i].AddSlit(line.PointAtStart, line.PointAtEnd, t, deeper);
                    slitPlanes[j].AddSlit(line.PointAtEnd, line.PointAtStart, t, deeper);
                }
            }


            // --- Output

            DA.SetEnum2D(0, slitPlanes.Select(o => o.GetResult()));
        }
开发者ID:olitur,项目名称:Bowerbird,代码行数:66,代码来源:BBSectionComponent.cs

示例3: Offset3D

        public List<Line> Offset3D(List<Polyline> x, double y)
        {
            List<Line> output = new List<Line>();
            if (x.Count < 4) return output;
            List<Line> lines = breakPoly(x[0]);

            for (int i = 1; i < x.Count; i++)
            {
                List<Line> ls = breakPoly(x[i]);
                //Print(ls.Count.ToString());
                for (int ii = 0; ii < ls.Count; ii++)
                {
                    bool sign = true;
                    for (int j = 0; j < lines.Count; j++)
                    {
                        if (isDumpLines(lines[j], ls[ii])) { sign = false; break; }
                    }
                    //Print(sign.ToString());
                    if (sign) lines.Add(ls[ii]);
                }
            }
            Point3d cen = new Point3d();
            for (int i = 0; i < lines.Count; i++)
            {
                cen += lines[i].From; cen += lines[i].To;
            }
            // B = lines;
            cen /= 2 * lines.Count;
            HullFrame.box box = new HullFrame.box(lines);
            HullFrame.hull hull = new HullFrame.hull(box, cen);
            for (int i = 0; i < x.Count; i++)
            {
                if (x[i].Count < 3)
                {//Print("00001");
                    return output;
                }
                Plane p = new Plane(x[i][0], x[i][1], x[i][2]);
                Vector3d v = cen - p.ClosestPoint(cen);
                v.Unitize(); p = new Plane(x[i][0], v);
                p.Transform(Transform.Translation(v * y));
                hull.intersect(p);
                hull.clearnull();
            }

            for (int i = 0; i < hull.edges.Count; i++)
            {
                output.Add(new Line(hull.edges[i].p1.pos, hull.edges[i].p2.pos));
            }
            List<Point3d> pt = new List<Point3d>();
            for (int i = 0; i < hull.pts.Count; i++)
            {
                pt.Add(hull.pts[i].pos);
            }
            return output;
        }
开发者ID:panhao4812,项目名称:MeshClassLibrary,代码行数:55,代码来源:HullFrame.cs


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