Example #1
0
        public void It_Returns_True_If_Points_Are_Planar()
        {
            // Arrange
            Point3        pt1    = new Point3(0.0, 0.0, 0.0);
            Point3        pt2    = new Point3(10.0, 0.0, 0.0);
            Point3        pt3    = new Point3(5.0, 5.0, 0.0);
            Point3        pt4    = new Point3(-5.0, -15.0, 0.0);
            List <Point3> points = new List <Point3> {
                pt1, pt2, pt3, pt4
            };

            // Arrange
            Trigonometry.ArePointsCoplanar(points).Should().BeTrue();
        }
Example #2
0
        /// <summary>
        ///   Find four points in the point cloud that are not coplanar for the
        ///   seed hull
        /// </summary>
        private void FindInitialHullIndices(List <Point3> points, out int b0, out int b1, out int b2, out int b3)
        {
            int count = points.Count;

            for (int i0 = 0; i0 < count - 3; i0++)
            {
                for (int i1 = i0 + 1; i1 < count - 2; i1++)
                {
                    Vector3 p0 = points[i0];
                    Vector3 p1 = points[i1];

                    if (p0.EpsilonEquals(p1, GSharkMath.MinTolerance))
                    {
                        continue;
                    }

                    for (int i2 = i1 + 1; i2 < count - 1; i2++)
                    {
                        Vector3 p2 = points[i2];

                        if (Trigonometry.ArePointsCollinear(p0, p1, p2))
                        {
                            continue;
                        }

                        for (int i3 = i2 + 1; i3 < count - 0; i3++)
                        {
                            Vector3 p3 = points[i3];

                            if (Trigonometry.ArePointsCoplanar(new List <Point3> {
                                p0, p1, p2, p3
                            }))
                            {
                                continue;
                            }

                            b0 = i0;
                            b1 = i1;
                            b2 = i2;
                            b3 = i3;
                            return;
                        }
                    }
                }
            }

            throw new System.ArgumentException("Can't generate hull, points are coplanar");
        }