Esempio n. 1
0
        /// <summary>
        /// Create member
        /// </summary>
        /// <param name="model">Idea open model</param>
        /// <param name="id">Member id</param>
        /// <param name="type">Member type</param>
        /// <param name="css">Cross section</param>
        /// <param name="startNode">Start node</param>
        /// <param name="endNode">End node</param>
        /// <returns>Connected member</returns>
        public static ConnectedMember CreateMember(OpenModel model, int id, Member1DType type, CrossSection css, string startNode, string endNode)
        {
            // create line segments
            LineSegment3D segment = CreateLineSegment3D(model, startNode, endNode);

            // create polylines
            PolyLine3D polyline = new PolyLine3D();

            polyline.Id = model.GetMaxId(polyline) + 1;
            polyline.Segments.Add(new ReferenceElement(segment));

            // add polylines and segments to the model
            model.AddObject(polyline);
            model.AddObject(segment);

            // create 1D elements
            Element1D element = CreateElement1D(model, css, segment);

            model.AddObject(element);

            // create 1D members
            Member1D member = CreateMember1D(model, id, type, element);

            model.Member1D.Add(member);

            // create and return connected member
            ConnectedMember connectedMember = new ConnectedMember();

            connectedMember.Id       = id;
            connectedMember.MemberId = new ReferenceElement(member);

            return(connectedMember);
        }
        public void IsParallelToWithinAngleTol(string s1, string e1, string s2, string e2, double degreesTol, bool expected)
        {
            var line1 = LineSegment3D.Parse(s1, e1);
            var line2 = LineSegment3D.Parse(s2, e2);

            Assert.AreEqual(expected, line1.IsParallelTo(line2, Angle.FromDegrees(degreesTol)));
        }
        public void DirectionsTest(string p1s, string p2s, string evs)
        {
            var l         = LineSegment3D.Parse(p1s, p2s);
            var excpected = UnitVector3D.Parse(evs, tolerance: 1);

            AssertGeometry.AreEqual(excpected, l.Direction);
        }
Esempio n. 4
0
        public static LineSegment3D[] GetSides(this Bounds b)
        {
            LineSegment3D[] sides   = new LineSegment3D[12];
            Vector3[]       corners = b.GetCorners();
            Vector3         corner0 = corners[0];
            Vector3         corner1 = corners[1];
            Vector3         corner2 = corners[2];
            Vector3         corner3 = corners[3];
            Vector3         corner4 = corners[4];
            Vector3         corner5 = corners[5];
            Vector3         corner6 = corners[6];
            Vector3         corner7 = corners[7];

            sides[0]  = new LineSegment3D(corner0, corner1);
            sides[1]  = new LineSegment3D(corner2, corner3);
            sides[2]  = new LineSegment3D(corner0, corner6);
            sides[3]  = new LineSegment3D(corner6, corner7);
            sides[4]  = new LineSegment3D(corner5, corner6);
            sides[5]  = new LineSegment3D(corner3, corner5);
            sides[6]  = new LineSegment3D(corner3, corner7);
            sides[7]  = new LineSegment3D(corner0, corner4);
            sides[8]  = new LineSegment3D(corner4, corner5);
            sides[9]  = new LineSegment3D(corner2, corner4);
            sides[10] = new LineSegment3D(corner1, corner7);
            sides[11] = new LineSegment3D(corner1, corner2);
            return(sides);
        }
        private ConnectedMember AddConnectedMember3point(int idMember, int idCss, int idPointA, int idPointB, int idPointC)
        {
            PolyLine3D polyLine3D = new PolyLine3D();

            polyLine3D.Id = idMember;
            openStructModel.AddObject(polyLine3D);

            //Segments

            LineSegment3D ls1 = new LineSegment3D();

            ls1.Id = openStructModel.GetMaxId(ls1) + 1;
            openStructModel.AddObject(ls1);
            ls1.StartPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointA));
            ls1.EndPoint   = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointB));
            polyLine3D.Segments.Add(new ReferenceElement(ls1));

            LineSegment3D ls2 = new LineSegment3D();

            ls2.Id = openStructModel.GetMaxId(ls2) + 1;
            openStructModel.AddObject(ls2);
            ls2.StartPoint = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointB));
            ls2.EndPoint   = new ReferenceElement(openStructModel.Point3D.First(c => c.Id == idPointC));
            polyLine3D.Segments.Add(new ReferenceElement(ls2));


            Element1D el1 = new Element1D();

            el1.Id                = openStructModel.GetMaxId(el1) + 1;
            el1.Name              = "E" + el1.Id;
            el1.Segment           = new ReferenceElement(ls1);
            el1.CrossSectionBegin = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss));
            el1.CrossSectionEnd   = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss));

            openStructModel.AddObject(el1);

            Element1D el2 = new Element1D();

            el2.Id                = openStructModel.GetMaxId(el2) + 1;
            el2.Name              = "E" + el2.Id;
            el2.Segment           = new ReferenceElement(ls2);
            el2.CrossSectionBegin = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss));
            el2.CrossSectionEnd   = new ReferenceElement(openStructModel.CrossSection.First(c => c.Id == idCss));
            openStructModel.AddObject(el2);

            Member1D mb = new Member1D();

            mb.Id   = idMember;
            mb.Name = "B" + mb.Id;
            mb.Elements1D.Add(new ReferenceElement(el1));
            mb.Elements1D.Add(new ReferenceElement(el2));
            openStructModel.Member1D.Add(mb);

            ConnectedMember conMb = new ConnectedMember();

            conMb.Id       = mb.Id;
            conMb.MemberId = new ReferenceElement(mb);
            return(conMb);
        }
        public void ClosestPointTo(string start, string end, string point, string expected)
        {
            var line = LineSegment3D.Parse(start, end);
            var p    = Point3D.Parse(point);
            var e    = Point3D.Parse(expected);

            Assert.AreEqual(e, line.ClosestPointTo(p));
        }
        public void Length(string p1s, string p2s, double expected)
        {
            var p1 = Point3D.Parse(p1s);
            var p2 = Point3D.Parse(p2s);
            var l  = new LineSegment3D(p1, p2);

            Assert.AreEqual(expected, l.Length, 1e-6);
        }
        [TestCase("6.0241017,5.1715162,5.7250655", "5.6868388,6.0031583,1.2902594", "3.4800129,9.7922534,2.4761596", "0.0589551,3.4081038,0.9383102", "5.6945715,5.9840905,1.3919397", "2.3316866,7.6493234,1.9599588")] // projection between segments, generated in GOM Inspect Professional V8
        public void ClosestPointsBetweenOnSegment(string s1, string e1, string s2, string e2, string cp1, string cp2)
        {
            var l1 = LineSegment3D.Parse(s1, e1);
            var l2 = LineSegment3D.Parse(s2, e2);

            Assert.AreEqual(true, l1.TryShortestLineTo(l2, Angle.FromRadians(0.00001), out var result));
            AssertGeometry.AreEqual(Point3D.Parse(cp1), result.StartPoint);
            AssertGeometry.AreEqual(Point3D.Parse(cp2), result.EndPoint);
        }
        public void TranslateBy(string spoint1, string spoint2, string svector, string spoint3, string spoint4)
        {
            var line     = LineSegment3D.Parse(spoint1, spoint2);
            var expected = LineSegment3D.Parse(spoint3, spoint4);
            var vector   = Vector3D.Parse(svector);

            Assert.AreEqual(expected.Length, line.Length);
            Assert.AreEqual(expected, line.TranslateBy(vector));
        }
        public void LineSegment3DBinaryFormatter(string p1s, string p2s)
        {
            Point3D p1     = Point3D.Parse(p1s);
            Point3D p2     = Point3D.Parse(p2s);
            var     l      = new LineSegment3D(p1, p2);
            var     result = this.BinaryFormmaterRoundTrip(l);

            Assert.AreEqual(l, result);
        }
Esempio n. 11
0
        public void LineSegment3DProtoBuf(string p1s, string p2s)
        {
            Point3D p1     = Point3D.Parse(p1s);
            Point3D p2     = Point3D.Parse(p2s);
            var     l      = new LineSegment3D(p1, p2);
            var     result = this.ProtobufRoundTrip(l);

            Assert.AreEqual(l, result);
        }
Esempio n. 12
0
        public void Equals(string p1s, string p2s, string p3s, string p4s, bool expected)
        {
            var line1 = new LineSegment3D(Point3D.Parse(p1s), Point3D.Parse(p2s));
            var line2 = new LineSegment3D(Point3D.Parse(p3s), Point3D.Parse(p4s));

            Assert.AreEqual(expected, line1.Equals(line2));
            Assert.AreEqual(expected, line1 == line2);
            Assert.AreEqual(!expected, line1 != line2);
        }
Esempio n. 13
0
        public void LineSegment3DDataContract(string p1s, string p2s, string xml)
        {
            Point3D p1     = Point3D.Parse(p1s);
            Point3D p2     = Point3D.Parse(p2s);
            var     l      = new LineSegment3D(p1, p2);
            var     result = this.DataContractRoundTrip(l, xml);

            Assert.AreEqual(l, result);
        }
Esempio n. 14
0
        public void LineSegment3DXml(string p1s, string p2s, string xml)
        {
            Point3D p1     = Point3D.Parse(p1s);
            Point3D p2     = Point3D.Parse(p2s);
            var     l      = new LineSegment3D(p1, p2);
            var     result = AssertXml.XmlSerializerRoundTrip(l, xml);

            Assert.AreEqual(l, result);
        }
Esempio n. 15
0
    public virtual float GetDirectedDistanceAlongParallel(Vector3 point)
    {
        Quaternion rotation = Quaternion.LookRotation(end - start);

        rotation = Quaternion.Inverse(rotation);
        LineSegment3D rotatedLine = Rotate(Vector3.zero, rotation);

        point = rotation * point;
        return(point.z - rotatedLine.start.z);
    }
Esempio n. 16
0
        public void ProjectLineOn()
        {
            var unitVector = UnitVector3D.ZAxis;
            var rootPoint  = new Point3D(0, 0, 1);
            var plane      = new Plane(unitVector, rootPoint);

            var line      = new LineSegment3D(new Point3D(0, 0, 0), new Point3D(1, 0, 0));
            var projectOn = plane.Project(line);

            AssertGeometry.AreEqual(new LineSegment3D(new Point3D(0, 0, 1), new Point3D(1, 0, 1)), projectOn, float.Epsilon);
        }
Esempio n. 17
0
        public void LineToTest(string p1s, string p2s, string ps, string sps)
        {
            var p1     = Point3D.Parse(p1s);
            var p2     = Point3D.Parse(p2s);
            var l      = new LineSegment3D(p1, p2);
            var p      = Point3D.Parse(ps);
            var actual = l.LineTo(p);

            AssertGeometry.AreEqual(Point3D.Parse(sps), actual.StartPoint, 1e-6);
            AssertGeometry.AreEqual(p, actual.EndPoint, 1e-6);
        }
Esempio n. 18
0
        /// <summary>
        /// Create element 1D
        /// </summary>
        /// <param name="model">Idea open model</param>
        /// <param name="css">Cross section</param>
        /// <param name="segment">Line segment</param>
        /// <returns>Element 1D</returns>
        private static Element1D CreateElement1D(OpenModel model, CrossSection css, LineSegment3D segment)
        {
            Element1D element1D = new Element1D();

            element1D.Id                = model.GetMaxId(element1D) + 1;
            element1D.Name              = "E" + element1D.Id.ToString();
            element1D.Segment           = new ReferenceElement(segment);
            element1D.CrossSectionBegin = new ReferenceElement(css);
            element1D.CrossSectionEnd   = new ReferenceElement(css);

            return(element1D);
        }
Esempio n. 19
0
        private double GetLength(OpenModel openStructModel, Member1D mb)
        {
            Element1D     el     = openStructModel.Element1D.First(c => c.Id == mb.Elements1D[0].Id);
            LineSegment3D seg    = openStructModel.LineSegment3D.First(c => c.Id == el.Segment.Id);
            Point3D       pA     = openStructModel.Point3D.First(c => c.Id == seg.StartPoint.Id);
            Point3D       pB     = openStructModel.Point3D.First(c => c.Id == seg.EndPoint.Id);
            Vector3D      vector = new Vector3D();

            vector.X = pA.X - pB.X;
            vector.Y = pA.Y - pB.Y;
            vector.Z = pA.Z - pB.Z;
            return(Math.Sqrt(((vector.X * vector.X) + (vector.Y * vector.Y) + (vector.Z * vector.Z))));
        }
Esempio n. 20
0
 void OnValidate()
 {
     if (Application.isPlaying)
     {
         return;
     }
     lineSegment                 = new LineSegment3D(trs.position + (trs.forward * (-Mathf.Abs(moveDistance) / 2 - axelOffset + distanceToAxelEnd)), trs.position + (trs.forward * (Mathf.Abs(moveDistance) / 2 - axelOffset + distanceToAxelEnd)));
     axelParent.position         = lineSegment.start + lineSegment.GetDirection() * extendAxel / 2;
     axelParent.localScale       = axelParent.localScale.SetZ(lineSegment.GetLength() + extendAxel);
     childObjectsParent.position = trs.position + (lineSegment.GetDirection() * (childObjectsOffset + distanceToAxelEnd));
     childObjectsParent.SetWorldScale(Vector3.one);
     SetMass();
 }
        public void SetLCS(AttachedMember attachedMember, LineSegment3D lineSegment)
        {
            //Defining LCS for First lineSegment
            double xcor = attachedMember.ElementRAZ.line.vector.X;
            double ycor = attachedMember.ElementRAZ.line.vector.Y;
            double zcor = attachedMember.ElementRAZ.line.vector.Z;



            //Define LCS (local-y in XY plane) and unitize
            VectorRAZ vx = new VectorRAZ(xcor, ycor, zcor).Unitize();
            VectorRAZ vy = new VectorRAZ();
            VectorRAZ vz = new VectorRAZ();

            if (xcor == 0.0 && ycor == 0.0)
            {
                vy = new VectorRAZ(0.0, 1.0, 0.0).Unitize();
                vz = new VectorRAZ((-zcor), 0.0, (xcor)).Unitize();
            }
            else
            {
                vy = new VectorRAZ(-ycor, xcor, 0.0).Unitize();
                vz = new VectorRAZ((-zcor * xcor), (-zcor * ycor), ((xcor * xcor) + (ycor * ycor))).Unitize();
            }

            if (attachedMember.ElementRAZ.rotationLCS == 0.0)
            {
            }
            else
            {
                vy = VectorRAZ.RotateVector(vx, attachedMember.ElementRAZ.rotationLCS, vy);
                vz = VectorRAZ.RotateVector(vx, attachedMember.ElementRAZ.rotationLCS, vz);
            }

            var LocalCoordinateSystem = new CoordSystemByVector();

            LocalCoordinateSystem.VecX = new Vector3D()
            {
                X = vx.X, Y = vx.Y, Z = vx.Z
            };
            LocalCoordinateSystem.VecY = new Vector3D()
            {
                X = vy.X, Y = vy.Y, Z = vy.Z
            };
            LocalCoordinateSystem.VecZ = new Vector3D()
            {
                X = vz.X, Y = vz.Y, Z = vz.Z
            };

            lineSegment.LocalCoordinateSystem = LocalCoordinateSystem;
        }
Esempio n. 22
0
        void Awake()
        {
            for (int i = 0; i < ignoreCollisionEntries.Length; i++)
            {
                IgnoreCollisionEntry ignoreCollisionEntry = ignoreCollisionEntries[i];
                Physics.IgnoreCollision(ignoreCollisionEntry.collider, ignoreCollisionEntry.otherCollider, true);
            }
#if UNITY_EDITOR
            rigidConstraints = rigid.constraints;
            if (Application.isPlaying)
#endif
            rigid.constraints = RigidbodyConstraints.FreezeAll;
            lineSegment       = new LineSegment3D(axelTrs.position, axelTrs.position + (axelParent.forward * moveDistance / 2));
        }
Esempio n. 23
0
    public virtual bool DoIIntersectWithLineSegment(LineSegment3D other, bool shouldIncludeEndPoints)
    {
        Vector3 da = end - start;
        Vector3 db = other.end - other.start;
        Vector3 dc = other.start - start;

        if (Vector3.Dot(dc, Vector3.Cross(da, db)) != 0)         // lines are not coplanar
        {
            return(false);
        }
        float s = Vector3.Dot(Vector3.Cross(dc, db), Vector3.Cross(da, db)) / Vector3.Dot(Vector3.Cross(da, db), Vector3.Cross(da, db));
        float t = Vector3.Dot(Vector3.Cross(dc, da), Vector3.Cross(da, db)) / Vector3.Dot(Vector3.Cross(da, db), Vector3.Cross(da, db));

        return(s >= 0 && s <= 1 && t >= 0 && t <= 1);
    }
Esempio n. 24
0
        /// <summary>
        /// Generate a single line only
        /// </summary>
        /// <param name="geom"></param>
        /// <param name="line"></param>
        /// <returns></returns>
        public static bool generate_Line(SdoGeometry geom, out List <LineSegment3D> lineList)
        {
            int[]    elInfo   = geom.ElemArrayOfInts;
            double[] ordArray = geom.OrdinatesArrayOfDoubles;

            lineList = new List <LineSegment3D>();
            for (int oCount = 0; oCount < ordArray.Count() / 6; oCount++)
            {
                Point3D       startP = new Point3D(ordArray[(oCount * 6) + 0], ordArray[(oCount * 6) + 1], ordArray[(oCount * 6) + 2]);
                Point3D       endP   = new Point3D(ordArray[(oCount * 6) + 3], ordArray[(oCount * 6) + 4], ordArray[(oCount * 6) + 5]);
                LineSegment3D line   = new LineSegment3D(startP, endP);
                lineList.Add(line);
            }
            return(true);
        }
Esempio n. 25
0
        /// <summary>
        /// Найти пересечение линии в пространстве и плоскости
        /// </summary>
        /// <param name="lineSegment"></param>
        /// <returns></returns>
        public Vector3D PointOfLineSegment3DCross(LineSegment3D lineSegment)
        {
            var ls = lineSegment;

            var d = A * ls.l + B * ls.m + C * ls.n;

            if (System.Math.Abs(d) < 0.00001)
            {
                return(null);                              //Пересечения нет
            }
            var t = (-(A * ls.A0.X + B * ls.A0.Y + C * ls.A0.Z + D)) / (A * ls.l + B * ls.m + C * ls.n);
            var x = System.Math.Round(ls.A0.X + ls.l * t, 10);
            var y = System.Math.Round(ls.A0.Y + ls.m * t, 10);
            var z = System.Math.Round(ls.A0.Z + ls.n * t, 10);

            return(new Vector3D(x, y, z));
        }
Esempio n. 26
0
        /// <summary>
        /// Create member
        /// </summary>
        /// <param name="model">Idea open model</param>
        /// <param name="id">Member id</param>
        /// <param name="type">Member type</param>
        /// <param name="css">Cross section</param>
        /// <param name="startNode">Start node</param>
        /// <param name="middleNode">Middle node</param>
        /// <param name="endNode">End node</param>
        /// <returns>Connected member</returns>
        public static ConnectedMember CreateMember(OpenModel model, int id, Member1DType type, CrossSection css, string startNode, string middleNode, string endNode)
        {
            // column members have different coordination system in our example
            bool transformCoordSystem = type == Member1DType.Column ? true : false;

            // create line segments
            LineSegment3D segment1 = CreateLineSegment3D(model, startNode, middleNode, transformCoordSystem);

            model.AddObject(segment1);

            LineSegment3D segment2 = CreateLineSegment3D(model, middleNode, endNode, transformCoordSystem);

            model.AddObject(segment2);

            // create polylines
            PolyLine3D polyline = new PolyLine3D();

            polyline.Id = model.GetMaxId(polyline) + 1;
            polyline.Segments.Add(new ReferenceElement(segment1));
            polyline.Segments.Add(new ReferenceElement(segment2));
            model.AddObject(polyline);

            // create 1D elements
            Element1D element1 = CreateElement1D(model, css, segment1);

            model.AddObject(element1);

            Element1D element2 = CreateElement1D(model, css, segment2);

            model.AddObject(element2);

            // create 1D members
            Member1D member = CreateMember1D(model, id, type, element1, element2);

            model.Member1D.Add(member);

            // create and return connected member
            ConnectedMember connectedMember = new ConnectedMember();

            connectedMember.Id       = id;
            connectedMember.MemberId = new ReferenceElement(member);

            return(connectedMember);
        }
        public void SetLCSwithRotation(AttachedMember attachedMember, LineSegment3D lineSegment)
        {
            //Explode x-vector
            double xcor = attachedMember.ElementRAZ.line.vector.X;
            double ycor = attachedMember.ElementRAZ.line.vector.Y;
            double zcor = attachedMember.ElementRAZ.line.vector.Z;

            VectorRAZ vx = new VectorRAZ(xcor, ycor, zcor).Unitize();

            double rotation = attachedMember.ElementRAZ.rotationLCS;

            //Explode z-vector
            double xcorZ = 0.0;
            double ycorZ = 0.0;
            double zcorZ = 0.0;

            VectorRAZ vz = new VectorRAZ(xcorZ, ycorZ, zcorZ).Unitize();

            //Create y-vector with cross-product
            VectorRAZ vy = new VectorRAZ();

            vz = new VectorRAZ((vz.Y * vx.Z - vx.Y * vz.Z), (-vz.X * vx.Z + vx.X * vz.Z), (vz.X * vx.Y - vx.X * vz.Y)).Unitize();

            //Set LCS
            var LocalCoordinateSystem = new CoordSystemByVector();

            LocalCoordinateSystem.VecX = new Vector3D()
            {
                X = vx.X, Y = vx.Y, Z = vx.Z
            };
            LocalCoordinateSystem.VecY = new Vector3D()
            {
                X = vy.X, Y = vy.Y, Z = vy.Z
            };
            LocalCoordinateSystem.VecZ = new Vector3D()
            {
                X = vz.X, Y = vz.Y, Z = vz.Z
            };

            lineSegment.LocalCoordinateSystem = LocalCoordinateSystem;
        }
Esempio n. 28
0
        /// <summary>
        /// Create line segment
        /// </summary>
        /// <param name="model">Idea open model</param>
        /// <param name="startNode">Start node</param>
        /// <param name="endNode">End node</param>
        /// <param name="transformCoordSystem">Tranform coordinate system</param>
        /// <returns>Line segment 3D</returns>
        private static LineSegment3D CreateLineSegment3D(OpenModel model, string startNode, string endNode, bool transformCoordSystem = false)
        {
            LineSegment3D segment3D = new LineSegment3D();

            segment3D.Id         = model.GetMaxId(segment3D) + 1;
            segment3D.StartPoint = new ReferenceElement(model.Point3D.FirstOrDefault(item => item.Name == startNode));
            segment3D.EndPoint   = new ReferenceElement(model.Point3D.FirstOrDefault(item => item.Name == endNode));

            if (transformCoordSystem)
            {
                CoordSystemByPoint system = new CoordSystemByPoint();
                system.Point = new Point3D()
                {
                    X = 100000, Y = 0, Z = 0
                };
                system.InPlane = Plane.ZX;
                segment3D.LocalCoordinateSystem = system;
            }

            return(segment3D);
        }
Esempio n. 29
0
        public void AddNode(Vector3 worldPosition)
        {
            if (Nodes.Count == 0)
            {
                AddNodeToEnd(worldPosition);
                return;
            }

            Node closestNode  = FindClosestNode(worldPosition);
            Node nextNode     = GetNextNode(closestNode);
            Node previousNode = GetPreviousNode(closestNode);

            LineSegment3D nextSegment     = new LineSegment3D(transform.TransformPoint(closestNode.Position), transform.TransformPoint(nextNode.Position));
            LineSegment3D previousSegment = new LineSegment3D(transform.TransformPoint(closestNode.Position), transform.TransformPoint(previousNode.Position));

            float nextSegmentDistance     = nextSegment.DistanceTo(worldPosition);
            float previousSegmentDistance = previousSegment.DistanceTo(worldPosition);

            Node node = new Node {
                Position = transform.InverseTransformPoint(worldPosition)
            };

            int currentNodeIndex = GetNodeIndex(closestNode);

            if (nextSegmentDistance < previousSegmentDistance)
            {
                if (currentNodeIndex == Nodes.Count - 1)
                {
                    Nodes.Add(node);
                }
                else
                {
                    Nodes.Insert(currentNodeIndex + 1, node);
                }
            }
            else
            {
                Nodes.Insert(currentNodeIndex, node);
            }
        }
Esempio n. 30
0
        void LineCrossTest(Plane plane)
        {
            var min = -5;
            var max = 5;

            for (int x1 = min; x1 < max; x1++)
            {
                for (int y1 = min; y1 < max; y1++)
                {
                    for (int z1 = min; z1 < max; z1++)
                    {
                        for (int x2 = min; x2 < max; x2++)
                        {
                            for (int y2 = min; y2 < max; y2++)
                            {
                                for (int z2 = min; z2 < max; z2++)
                                {
                                    if (x1 != x2 && y1 != y2 && z1 != z2)
                                    {
                                        var p1 = new Vector3D(x1, y1, z1);

                                        var p2 = new Vector3D(x2, y2, z2);

                                        var ls = new LineSegment3D(p1, p2);

                                        var crossPoint = plane.PointOfLineSegment3DCross(ls);
                                        if (crossPoint != null)
                                        {
                                            Assert.IsTrue(plane.Contains(crossPoint));
                                            Assert.IsTrue(ls.Contains(crossPoint));
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }