public void Given_Point3Ds_Equality_Checks()
        {
            var p = new Point3D(1, 1, 1);
            var r = new Point3D(2, 2, 2);
            var q = new Point3D(1, 1, 1);

            Assert.IsTrue(p.Equals(p));
            Assert.IsFalse(p.Equals(null));
            Assert.IsFalse(p.Equals("Point3D"));
            Assert.IsFalse(p.Equals(r));
            Assert.IsTrue(p.Equals(q));
            Assert.IsTrue(q.Equals(p));
        }
Example #2
0
 public bool Equals(Triangle other)
 {
     if (p1.Equals(other.p1) | p1.Equals(other.p2) | p1.Equals(other.p3))
     {
         if (p2.Equals(other.p1) | p2.Equals(other.p2) | p2.Equals(other.p3))
         {
             if (p3.Equals(other.p1) | p3.Equals(other.p2) | p3.Equals(other.p3))
             {
                 return(true);
             }
         }
     }
     return(false);
 }
Example #3
0
        public void TestVeryBasicPushingPolygonAByPolygon()
        {
            // save positions
            Point3D originalPosPoly1 = m_tilesWorld.ToList()[1].Position;
            Point3D originalPosLine1 = m_tilesWorld.ToList()[2].Position;

            // XJB DEBUG - mathSage string is there to follow what happened
            string mathSageBefore = DumpTilesWorldToSageMath();

            // add object and perform health check
            Assert.IsTrue(m_tilesWorld.Add(m_testMSystem.Tiles["q1"], m_tilesWorld.ToList()[0].Connectors[0], out newlyCreatedTile));
            PerformHealthCheck();

            // get current position of the polygon, position must be different
            Point3D newPosPoly1 = m_tilesWorld.ToList()[1].Position;

            // XJB DEBUG - mathSage string is there to follow what happened
            string mathSageAfter = DumpTilesWorldToSageMath();

            Assert.AreNotEqual(originalPosPoly1, newPosPoly1);
            Point3D expectedPosPoly1 = new Point3D(11.5219303466815, 14.7294308566871, 31.9967477524977);

            Assert.IsTrue(expectedPosPoly1.Equals(newPosPoly1, MSystem.Tolerance));

            // get current position of the line, positions must be the same
            Point3D newPosLine1 = m_tilesWorld.ToList()[2].Position;

            Assert.AreEqual(originalPosLine1, newPosLine1);
        }
        /// <summary>
        /// Creates a new <see cref="Point3D"/> from the collection of <paramref name="valuesRead"/>, by using
        /// the <paramref name="typeKey"/> to create the column identifiers to read from.
        /// </summary>
        /// <param name="valuesRead">The collection of read data.</param>
        /// <param name="typeKey">The key for the type of characteristic point.</param>
        /// <param name="locationName">The name of the location used for creating descriptive errors.</param>
        /// <returns>A new <see cref="Point3D"/> with values for x,y,z set.</returns>
        /// <exception cref="LineParseException">Thrown when <paramref name="valuesRead"/>
        /// contains a value which could not be parsed to a double in the column that had to be read for creating
        /// the <see cref="Point3D"/>.</exception>
        private Point3D GetPoint3D(string[] valuesRead, string typeKey, string locationName)
        {
            try
            {
                Point3D point      = null;
                string  xColumnKey = xPrefix + typeKey;
                if (columnsInFile.ContainsKey(xColumnKey))
                {
                    int xColumnIndex = columnsInFile[xColumnKey];
                    int yColumnIndex = columnsInFile[yPrefix + typeKey];
                    int zColumnIndex = columnsInFile[zPrefix + typeKey];

                    point = new Point3D(
                        double.Parse(valuesRead[xColumnIndex], CultureInfo.InvariantCulture),
                        double.Parse(valuesRead[yColumnIndex], CultureInfo.InvariantCulture),
                        double.Parse(valuesRead[zColumnIndex], CultureInfo.InvariantCulture)
                        );

                    if (point.Equals(undefinedPoint))
                    {
                        point = null;
                    }
                }

                return(point);
            }
            catch (FormatException e)
            {
                throw CreateLineParseException(lineNumber, locationName, Resources.Error_CharacteristicPoint_has_not_double, e);
            }
            catch (OverflowException e)
            {
                throw CreateLineParseException(lineNumber, locationName, Resources.Error_CharacteristicPoint_parsing_causes_overflow, e);
            }
        }
Example #5
0
        private List <Point3D> FindBox(Point3D lower, Point3D upper, List <NanoRobot> robots)
        {
            if (lower.Equals(upper))
            {
                return(new List <Point3D> {
                    lower
                });
            }

            List <KeyValuePair <Point3D, Point3D> > octals = GenerateOctals(lower, upper);

            Dictionary <KeyValuePair <Point3D, Point3D>, int> hitByRobots = HitByRobots(octals, robots);

            Dictionary <KeyValuePair <Point3D, Point3D>, int> sorted = hitByRobots.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value);

            int highest = sorted.First().Value;

            List <Point3D> points = null;

            foreach (var lowestOctals in sorted.Where(x => x.Value == highest))
            {
                points = FindBox(lowestOctals.Key.Key, lowestOctals.Key.Value, robots);
            }

            return(points);
        }
        public String train(Device dev)
        {
            if (dev == null)
            {
                return(Properties.Resources.SpecifiedDeviceNotFound);
            }

            Console.Out.WriteLine("CurrentList length:" + dev.skelPositions.Count);

            //Line3D.updateWeight(lines);

            //calculate new Position
            if (dev.skelPositions.Count < Locator.MIN_NUMBER_OF_VECTORS)
            {
                return(Properties.Resources.MoreVectorsRequired);
            }

            Point3D position = locator.getDeviceLocation(dev.skelPositions);

            // vectors were used for calculation, clear list
            dev.skelPositions.Clear();

            if (position.Equals(new Point3D(Double.NaN, Double.NaN, Double.NaN)))
            {
                //error: advise user to try again
                return(Properties.Resources.CalculationError);
            }

            //change position of device in dataHolder

            Data.changeDeviceCoordinates(dev.Id, "0,3", position);

            return(String.Format(Properties.Resources.DevCoordsReplaced, dev.Name));
        }
Example #7
0
    public static void Main()
    {
        Point   point2D  = new Point(5, 5);
        Point3D point3Da = new Point3D(5, 5, 2);
        Point3D point3Db = new Point3D(5, 5, 2);
        Point3D point3Dc = new Point3D(5, 5, -1);

        Console.WriteLine("{0} = {1}: {2}",
                          point2D, point3Da, point2D.Equals(point3Da));
        Console.WriteLine("{0} = {1}: {2}",
                          point2D, point3Db, point2D.Equals(point3Db));
        Console.WriteLine("{0} = {1}: {2}",
                          point3Da, point3Db, point3Da.Equals(point3Db));
        Console.WriteLine("{0} = {1}: {2}",
                          point3Da, point3Dc, point3Da.Equals(point3Dc));
    }
Example #8
0
        public void Execute()
        {
            PointWithoutOverride pointA = new PointWithoutOverride {
                X = 1, Y = 2
            };
            PointWithoutOverride pointB = new PointWithoutOverride {
                X = 1, Y = 2
            };

            var result  = pointA.Equals(pointB); // false (reference equals)
            var result5 = pointA == pointB;      // false (reference equals)

            pointA = pointB;

            var result2  = pointA.Equals(pointB); // true (reference equals)
            var result5B = pointA == pointB;      // true (reference equals)

            Point point2dA = new Point {
                X = 1, Y = 2
            };
            Point3D point3dA = new Point3D {
                X = 1, Y = 2, Z = 3
            };
            Point3D point3dB = new Point3D {
                X = 1, Y = 2, Z = 3
            };

            var result3 = point2dA.Equals(point3dA); // true
            var result4 = point3dA.Equals(point3dB); // true

            ;
        }
Example #9
0
 public bool Equals(HeadPose other)
 {
     return(Landmarks.SequenceEqual(other.Landmarks) &&
            VisiableLandmarks.SequenceEqual(other.VisiableLandmarks) &&
            Landmarks3D.SequenceEqual(other.Landmarks3D) &&
            Position.Equals(other.Position) &&
            Angle.Equals(other.Angle));
 }
        private static void PrintAdHocResults()
        {
            var perimeter = new Perimeter();
            var display   = perimeter.CalculatePerimeter(new Tuple <double, double, double>(1, 1, 1),
                                                         new Tuple <double, double, double>(1, 1, 5), new Tuple <double, double, double>(1, 1, 3));

            if (display != null)
            {
                Console.WriteLine(display);
            }

            var point1 = new Point3D(1, 1, 1);
            var point2 = new Point3D(1, 1, 1);
            var point3 = new Point3D(3, 3, 3);

            Console.WriteLine($"{point1.Equals(point2)} and {point1.Equals(point3)}");
        }
Example #11
0
 void InitPosition()
 {
     if (NowPosition.Equals(new Point3D(0, 0, Config.InitLiftZmm)) == false)
     {
         SetSpeedFactor(200);
         MoveToZ(Config.InitLiftZmm);
         MoveTo3DPointSimultaneous(new Point3D(0, 0, -1));
     }
 }
        public static void EffectLine(Point3D start, Point3D end, Map map)
        {
            if (start.Equals(end))
            {
                return;
            }

            int difX = Math.Abs(start.X - end.X);
            int difY = Math.Abs(start.Y - end.Y);

            int x = start.X;
            int y = start.Y;

            int avgX = (int)Math.Round(difY != 0 ? difX / (double)difY : 0);
            int avgY = (int)Math.Round(difX != 0 ? difY / (double)difX : 0);

            while (x != end.X && y != end.Y)
            {
                Point3D p = new Point3D(x, y, start.Z);

                if (map.CanFit(p, 12, true, false))
                {
                    Effects.SendLocationEffect(p, map, 0x376A, 4, 9);
                }

                if (avgX <= 0)
                {
                    if (x < end.X)
                    {
                        x += 1;
                    }
                    else if (x > end.X)
                    {
                        x -= 1;
                    }
                    avgX = (int)Math.Round(difY != 0 ? difX / (double)difY : 0);
                }

                if (avgY <= 0)
                {
                    if (y < end.Y)
                    {
                        y += 1;
                    }
                    else if (y > end.Y)
                    {
                        y -= 1;
                    }

                    avgY = (int)Math.Round(difX != 0 ? difY / (double)difX : 0);
                }

                avgX -= 1;
                avgY -= 1;
            }
        }
Example #13
0
 public void SetLimits(Point3D position)
 {
     if (!position.Equals(_limits))
     {
         _limits.X = position.X;
         _limits.Y = position.Y;
         _limits.Z = position.Z;
         OnPropertyChanged(nameof(Limits));
     }
 }
Example #14
0
        public void TestSubPointVector()
        {
            Point3D  pointA        = new Point3D(2, 2, 2);
            Vector3D vectorA       = new Vector3D(1, 1, 1);
            Point3D  actualPointer = pointA - vectorA;

            Point3D expected = new Point3D(1, 1, 1);

            Assert.IsTrue(actualPointer.Equals(expected));
        }
Example #15
0
        public void TestProductScalePoint()
        {
            Double  scaleA        = 2.0;
            Point3D pointA        = new Point3D(2, 2, 2);
            Point3D actualPointer = scaleA * pointA;

            Point3D expected = new Point3D(4.0, 4.0, 4.0);

            Assert.IsTrue(actualPointer.Equals(expected));
        }
Example #16
0
 public void SetStartPosition(Point3D position)
 {
     if (!position.Equals(_startposition))
     {
         _startposition.X = position.X;
         _startposition.Y = position.Y;
         _startposition.Z = position.Z;
         OnPropertyChanged(nameof(StartPosition));
     }
 }
Example #17
0
        public void TestAddPoints()
        {
            Point3D pointA        = new Point3D(0, 2, 1);
            Point3D pointB        = new Point3D(1, 2, -1);
            Point3D actualPointer = pointA + pointB;

            Point3D expected = new Point3D(1, 4, 0);

            Assert.IsTrue(actualPointer.Equals(expected));
        }
Example #18
0
        /// <summary>
        /// Equals - compares this Point3D with the passed in object.  In this equality
        /// Double.NaN is equal to itself, unlike in numeric equality.
        /// Note that double values can acquire error when operated upon, such that
        /// an exact comparison between two values which
        /// are logically equal may fail.
        /// </summary>
        /// <returns>
        /// bool - true if the object is an instance of Point3D and if it's equal to "this".
        /// </returns>
        /// <param name='o'>The object to compare to "this"</param>
        public override bool Equals(object o)
        {
            if ((null == o) || !(o is Point3D))
            {
                return(false);
            }

            Point3D value = (Point3D)o;

            return(Point3D.Equals(this, value));
        }
Example #19
0
        public void EqualsTest()
        {
            Point3D target   = new Point3D(); // TODO: 初始化为适当的值
            object  xObject  = null;          // TODO: 初始化为适当的值
            bool    expected = false;         // TODO: 初始化为适当的值
            bool    actual;

            actual = target.Equals(xObject);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("验证此测试方法的正确性。");
        }
Example #20
0
        public void TestIntersect_WithValidCalculationsOfHitPoint()
        {
            //Arrange
            Vector3D rayDirection = new Vector3D(-0.6, -0.8, -0.99);
            Ray      testRay      = new Ray(rayOrigin, rayDirection);
            //Act
            HitInfo hitInfoTest   = planeTest.Intersect(testRay);
            Point3D expectedPoint = rayOrigin + (rayDirection * hitInfoTest.tMin);

            //Assert
            Assert.IsTrue(expectedPoint.Equals(hitInfoTest.hitPoint));
        }
Example #21
0
        public override bool Equals(object o)
        {
            if (!(o is PharmacophoreAtom))
            {
                return(false);
            }

            PharmacophoreAtom that = (PharmacophoreAtom)o;

            return(Smarts.Equals(that.Smarts, StringComparison.Ordinal) && Symbol.Equals(that.Symbol, StringComparison.Ordinal) &&
                   Point3D.Equals(that.Point3D) && Arrays.AreEqual(this.matchingAtoms, that.matchingAtoms));
        }
Example #22
0
        public void Point3D_SerializableTest()
        {
            Point3D p = new Point3D()
            {
                X = 1, Y = 2, Z = 3
            };
            string xmlText = XmlTool.Serialize(typeof(Point3D), p);

            Assert.IsNotNull(xmlText);
            Point3D pd = XmlTool.Deserialize(typeof(Point3D), xmlText) as Point3D;

            Assert.IsTrue(p.Equals(pd));
        }
Example #23
0
        public void ConvertByMatrix(Matrix3D matrix)
        {
            if (originalPoint1.Equals(new Point3D(int.MaxValue, int.MaxValue, int.MaxValue)) &&
                originalPoint2.Equals(new Point3D(int.MaxValue, int.MaxValue, int.MaxValue)))
            {
                originalPoint1 = new Point3D(X1, Y1, Z1);
                originalPoint2 = new Point3D(X2, Y2, Z2);
            }

            var first  = matrix.Transform(new Point3D(originalPoint1.X, originalPoint1.Y, originalPoint1.Z));
            var second = matrix.Transform(new Point3D(originalPoint2.X, originalPoint2.Y, originalPoint2.Z));

            X1 = first.X;
            Y1 = first.Y;
            Z1 = first.Z;
            X2 = second.X;
            Y2 = second.Y;
            Z2 = second.Z;



            //var newX1 = X1 * matrix.M11 + Y1 * matrix.M21 + Z1 * matrix.M31 + matrix.OffsetX;
            //var newY1 = X1 * matrix.M12 + Y1 * matrix.M22 + Z1 * matrix.M32 + matrix.OffsetY;
            //var newZ1 = X1 * matrix.M13 + Y1 * matrix.M22 + Z1 * matrix.M33 + matrix.OffsetZ;

            //var newX2 = X2 * matrix.M11 + Y2 * matrix.M21 + Z2 * matrix.M31 + matrix.OffsetX;
            //var newY2 = X2 * matrix.M12 + Y2 * matrix.M22 + Z2 * matrix.M32 + matrix.OffsetY;
            //var newZ2 = X2 * matrix.M13 + Y2 * matrix.M22 + Z2 * matrix.M33 + matrix.OffsetZ;

            //X1 = newX1;
            //Y1 = newY1;
            //Z1 = newZ1;

            //X2 = newX2;
            //Y2 = newY2;
            //Z2 = newZ2;
        }
Example #24
0
                public static void Main(String[] args)
                {
                    Point2D p1 = new Point2D();
                    Point2D p2 = new Point2D(7, 5);
                    Point2D p3 = new Point2D(-2, 4);
                    Point2D p4 = new Point2D(7, 5);

                    Console.WriteLine("p1 = {0}", p1);
                    Console.WriteLine("p2 = {0}", p2);
                    Console.WriteLine("p3 = {0}", p3);
                    Console.WriteLine("p4 = {0}", p4);

                    Console.WriteLine("p2 == p3? {0}", p2 == p3);
                    Console.WriteLine("p2.Equals(p3)? {0}", p2.Equals(p3));
                    Console.WriteLine("p2 == p4? {0}", p2 == p4);
                    Console.WriteLine("p2.Equals(p4)? {0}", p2.Equals(p4));

                    Console.WriteLine("========");

                    Point3D p5 = new Point3D();
                    Point3D p6 = new Point3D(7, 5, 12);
                    Point3D p7 = new Point3D(-2, 4, -4);
                    Point3D p8 = new Point3D(7, 5, 12);

                    Console.WriteLine("p5 = {0}", p5);
                    Console.WriteLine("p6 = {0}", p6);
                    Console.WriteLine("p7 = {0}", p7);
                    Console.WriteLine("p8 = {0}", p8);

                    Console.WriteLine("p6 == p7? {0}", p6 == p7);
                    Console.WriteLine("p6.Equals(p7)? {0}", p6.Equals(p7));
                    Console.WriteLine("p6 == p8? {0}", p6 == p8);
                    Console.WriteLine("p6.Equals(p8)? {0}", p6.Equals(p8));

                    Console.WriteLine("========");
                }
Example #25
0
        /// <summary>
        /// Returns closes point from given input point for provided point list.
        /// </summary>
        private Point3D GetClosestPoint(Point3D point3D, Point3D[] intersetionPoints)
        {
            double  minsquaredDist = Double.MaxValue;
            Point3D result         = null;

            foreach (Point3D pt in intersetionPoints)
            {
                double distSquared = Point3D.DistanceSquared(point3D, pt);
                if (distSquared < minsquaredDist && !point3D.Equals(pt))
                {
                    minsquaredDist = distSquared;
                    result         = pt;
                }
            }
            return(result);
        }
Example #26
0
        public void TestVeryBasicPushingLineByPolygon()
        {
            // save positions
            Point3D originalPosPoly1 = m_tilesWorld.ToList()[1].Position;
            Point3D originalPosLine1 = m_tilesWorld.ToList()[2].Position;

            // add object and perform health check
            Assert.IsTrue(m_tilesWorld.Add(m_testMSystem.Tiles["q1"], m_tilesWorld.ToList()[0].Connectors[2], out newlyCreatedTile));
            PerformHealthCheck();

            // get current position of the line, position must be different
            Point3D newPosLine1 = m_tilesWorld.ToList()[2].Position;

            Assert.AreNotEqual(originalPosLine1, newPosLine1);
            Point3D expectedPosLine1 = new Point3D(3, -24.3539038811117, 27.7078077622233);

            Assert.IsTrue(expectedPosLine1.Equals(newPosLine1, MSystem.Tolerance));

            // get current position of the polygon, positions must be the same
            Point3D newPosPoly1 = m_tilesWorld.ToList()[1].Position;

            Assert.AreEqual(originalPosPoly1, newPosPoly1);
        }
Example #27
0
        public void TestProjectComplex()
        {
            // case 1
            Point3D p1      = new Point3D(3, 15, -6);
            Point3D p2      = new Point3D(1, 3, 4);
            Point3D p3      = new Point3D(13, 9, 7);
            Plane   myPlane = new Plane(p1, p2, p3);

            Point3D projectedPoint = new Point3D(4, -8, 12);
            Point3D resultPoint    = myPlane.Project(projectedPoint);
            Point3D expectPoint    = new Point3D(3076.0 / 1181, -7285.0 / 1181, 16438.0 / 1181);

            Assert.IsTrue(expectPoint.Equals(resultPoint, MapleTolerance));

            // case 2
            p1      = new Point3D(6.32, -.34, -4.99);
            p2      = new Point3D(3.14, -6.28, 2.71);
            p3      = new Point3D(12.89, -56.33, 98.34);
            myPlane = new Plane(p1, p2, p3);

            projectedPoint = new Point3D(15.34, 14.36, -56.76);
            resultPoint    = myPlane.Project(projectedPoint);
            expectPoint    = new Point3D(9.384840357, 26.72232629, -49.68275189);
            Assert.IsTrue(expectPoint.Equals(resultPoint, MapleTolerance));

            // case 3
            p1      = new Point3D(-45.786, -2.091, 67.233);
            p2      = new Point3D(93.143, -26.288, 28.751);
            p3      = new Point3D(-101.089, 56.393, 89.344);
            myPlane = new Plane(p1, p2, p3);

            projectedPoint = new Point3D(34.354, -34.346, -0.1e-2);
            resultPoint    = myPlane.Project(projectedPoint);
            expectPoint    = new Point3D(44.26955989, -39.80031099, 39.22608754);
            Assert.IsTrue(expectPoint.Equals(resultPoint, MapleTolerance));
        }
Example #28
0
        public static bool generate_Polyhedron(SdoGeometry geom, out Polyhedron pH)
        {
            List <double> pointCoordList = new List <double>();
            List <int>    coordIndexList = new List <int>();

            int[]    elInfo   = geom.ElemArrayOfInts;
            double[] ordArray = geom.OrdinatesArrayOfDoubles;

            if (ordArray.Length == 0)
            {
                // An empty data (should not come here, but in some cases it may happen when there is bad data)
                pH = null;
                return(false);
            }

            int        eInfoIdx       = 0; // Index on Element Info array
            int        vertIdx        = 0; // new Index for the index to the vertex coordinate lists
            Point3D    v              = new Point3D();
            Point3D    v1             = new Point3D();
            List <int> noFaceVertList = new List <int>();

            // First loop: loop for lump
            while (eInfoIdx < elInfo.Length)
            {
                // advance to the 6th array in the element info to get the number of faces
                eInfoIdx += 5;
                int noFace = elInfo[eInfoIdx];

                eInfoIdx += 1;      // Advance to the first face offset

                // second loop for the number of faces inside a lump
                for (int f = 0; f < noFace; f++)
                {
                    bool vert   = true;
                    int  vcount = 0;
                    int  fIdx   = elInfo[eInfoIdx];

                    while (vert)
                    {
                        if (vcount == 0)
                        {
                            v1.X = ordArray[fIdx - 1];     // -1 because the index starts at no 1
                            v1.Y = ordArray[fIdx];
                            v1.Z = ordArray[fIdx + 1];

                            pointCoordList.Add(v1.X);
                            pointCoordList.Add(v1.Y);
                            pointCoordList.Add(v1.Z);
                            coordIndexList.Add(vertIdx * 3);
                            vertIdx++;
                            vcount++;
                            fIdx += 3;
                            continue;
                        }
                        v.X = ordArray[fIdx - 1];
                        v.Y = ordArray[fIdx];
                        v.Z = ordArray[fIdx + 1];

                        if (Point3D.Equals(v, v1))
                        {
                            // We are at the end of the vertex list. Oracle SDO repeat the last point as the first point, we can skip this for X3D
                            vert      = false;
                            eInfoIdx += 3;
                            noFaceVertList.Add(vcount);     // List of no of vertices in each individual face
                            continue;
                        }

                        pointCoordList.Add(v.X);
                        pointCoordList.Add(v.Y);
                        pointCoordList.Add(v.Z);
                        coordIndexList.Add(vertIdx * 3);
                        fIdx += 3;
                        vertIdx++;
                        vcount++;
                    }
                }
            }

//            pH = new Polyhedron(PolyhedronFaceTypeEnum.TriangleFaces, true, pointCoordList, coordIndexList, null);
            pH = new Polyhedron(PolyhedronFaceTypeEnum.ArbitraryFaces, true, pointCoordList, coordIndexList, noFaceVertList);
            return(true);
        }
Example #29
0
        // This method performs the Point3D operations
        //<SnippetMil3DPoints3DN1>
        private void PerformOperation(object sender, RoutedEventArgs e)
        {
            RadioButton li = (sender as RadioButton);

            // Strings used to display the results
            String syntaxString, resultType, operationString;

            // The local variables point1, point2, vector2, etc are defined in each
            // case block for readability reasons. Each variable is contained within
            // the scope of each case statement.
            switch (li.Name)
            {               //begin switch
            //</SnippetMil3DPoints3DN1>
            case "rb1":
            {
                //<SnippetMil3DPoints3DN3>
                // Translates a Point3D by a Vector3D using the overloaded + operator.
                // Returns a Point3D.

                Point3D  point1      = new Point3D(10, 5, 1);
                Vector3D vector1     = new Vector3D(20, 30, 40);
                Point3D  pointResult = new Point3D();

                pointResult = point1 + vector1;
                // point3DResult is equal to (30, 35, 41)

                // Displaying Results
                syntaxString    = "pointResult = point1 + vector1;";
                resultType      = "Point3D";
                operationString = "Adding a 3D Point and a 3D Vector";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN3>
                break;
            }

            case "rb2":
            {
                //<SnippetMil3DPoints3DN4>
                // Translates a Point3D by a Vector3D using the static Add method.
                // Returns a Point3D.

                Point3D  point1      = new Point3D(10, 5, 1);
                Vector3D vector1     = new Vector3D(20, 30, 40);
                Point3D  pointResult = new Point3D();

                pointResult = Point3D.Add(point1, vector1);
                // pointResult is equal to (30, 35, 41)

                // Displaying Results
                syntaxString    = "pointResult = Point3D.Add(point1, vector1);";
                resultType      = "Point3D";
                operationString = "Adding a 3D Point and a 3D Vector";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN4>
                break;
            }

            case "rb3":
            {
                //<SnippetMil3DPoints3DN5>
                // Subtracts a Vector3D from a Point3D using the overloaded - operator.
                // Returns a Point3D.

                Point3D  point1      = new Point3D(10, 5, 1);
                Vector3D vector1     = new Vector3D(20, 30, 40);
                Point3D  pointResult = new Point3D();

                pointResult = point1 - vector1;
                // pointResult is equal to (-10, -25, -39)

                // Displaying Results
                syntaxString    = "pointResult = point1 - vector1;";
                resultType      = "Point3D";
                operationString = "Subtracting a Vector3D from a Point3D";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN5>
                break;
            }

            case "rb4":
            {
                //<SnippetMil3DPoints3DN6>
                // Subtracts a Vector3D from a Point3D using the static Subtract method.
                // Returns a Point3D.

                Point3D  point1      = new Point3D(10, 5, 1);
                Vector3D vector1     = new Vector3D(20, 30, 40);
                Point3D  pointResult = new Point3D();

                pointResult = Point3D.Subtract(point1, vector1);
                // pointResult is equal to (-10, -25, -39)

                // Displaying Results
                syntaxString    = "pointResult = Point3D.Subtract(point1, vector1);";
                resultType      = "Point3D";
                operationString = "Subtracting a Vector3D from a Point3D";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN6>
                break;
            }

            case "rb5":
            {
                //<SnippetMil3DPoints3DN7>
                // Subtracts a Point3D from a Point3D using the overloaded - operator.
                // Returns a Vector3D.

                Point3D  point1       = new Point3D(10, 5, 1);
                Point3D  point2       = new Point3D(15, 40, 60);
                Vector3D vectorResult = new Vector3D();

                vectorResult = point1 - point2;
                // vectorResult is equal to (-5, -35, -59)

                // Displaying Results
                syntaxString    = " vectorResult = point1 - point2;";
                resultType      = "Vector3D";
                operationString = "Subtracting a Point3D from a Point3D";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN7>
                break;
            }

            case "rb6":
            {
                //<SnippetMil3DPoints3DN8>
                // Subtracts a Point3D from a Point3D using the static Subtract method.
                // Returns a Vector3D.

                Point3D  point1       = new Point3D(10, 5, 1);
                Point3D  point2       = new Point3D(15, 40, 60);
                Vector3D vectorResult = new Vector3D();

                vectorResult = Point3D.Subtract(point1, point2);
                // vectorResult is equal to (-5, -35, -59)

                // Displaying Results
                syntaxString    = "vectorResult = Point3D.Subtract(point1, point2);";
                resultType      = "Vector3D";
                operationString = "Subtracting a Point3D from a Point3D";
                ShowResults(vectorResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN8>
                break;
            }

            case "rb7":
            {
                //<SnippetMil3DPoints3DN9>
                // Offsets the X, Y and Z values of a Point3D.

                Point3D point1 = new Point3D(10, 5, 1);

                point1.Offset(20, 30, 40);
                // point1 is equal to (30, 35, 41)

                // Note: This operation is equivalent to adding a point
                // to vector with the corresponding X,Y, Z values.

                // Displaying Results
                syntaxString    = "point1.Offset(20, 30, 40);";
                resultType      = "Point3D";
                operationString = "Offsetting a Point3D";
                ShowResults(point1.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN9>
                break;
            }

            case "rb8":
            {
                //<SnippetMil3DPoints3DN10>
                // Multiplies a Point3D by a Matrix.
                // Returns a Point3D.

                Point3D  point1      = new Point3D(10, 5, 1);
                Point3D  pointResult = new Point3D();
                Matrix3D matrix1     = new Matrix3D(10, 10, 10, 0, 20, 20, 20, 0, 30, 30, 30, 0, 5, 10, 15, 1);

                pointResult = point1 * matrix1;
                // pointResult is equal to (235, 240, 245)

                // Displaying Results
                resultType      = "Point3D";
                syntaxString    = "pointResult = point1 * matrix1;";
                operationString = "Multiplying a Point3D by a Matrix3D";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN10>
                break;
            }

            case "rb9":
            {
                //<SnippetMil3DPoints3DN11>
                // Multiplies a Point3D by a Matrix.
                // Returns a Point3D.

                Point3D  point1      = new Point3D(10, 5, 1);
                Point3D  pointResult = new Point3D();
                Matrix3D matrix1     = new Matrix3D(10, 10, 10, 0, 20, 20, 20, 0, 30, 30, 30, 0, 5, 10, 15, 1);

                pointResult = Point3D.Multiply(point1, matrix1);
                // pointResult is equal to (235, 240, 245)

                // Displaying Results
                resultType      = "Point3D";
                syntaxString    = "pointResult = Point3D.Multiply(point1, matrix1);";
                operationString = "Multiplying a Point3D by a Matrix";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN11>
                break;
            }

            case "rb10":
            {
                //<SnippetMil3DPoints3DN12>
                // Checks if two Point3Ds are equal using the overloaded equality operator.

                Point3D point1 = new Point3D(10, 5, 1);
                Point3D point2 = new Point3D(15, 40, 60);
                Boolean areEqual;

                areEqual = (point1 == point2);
                // areEqual is False

                // Displaying Results
                syntaxString    = "areEqual = (point1 == point2);";
                resultType      = "Boolean";
                operationString = "Checking if two 3D points are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN12>
                break;
            }


            case "rb11":
            {
                //<SnippetMil3DPoints3DN13>
                // Checks if two Point3D structures are equal using the static Equals method.

                Point3D point1 = new Point3D(10, 5, 1);
                Point3D point2 = new Point3D(15, 40, 60);
                Boolean areEqual;

                areEqual = Point3D.Equals(point1, point2);
                // areEqual is False

                //Displaying Results
                syntaxString    = "areEqual = Point3D.Equals(point1, point2);";
                resultType      = "Boolean";
                operationString = "Checking if 3D two points are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN13>
                break;
            }

            case "rb12":
            {
                //<SnippetMil3DPoints3DN14>
                // Compares an Object and a Point3D for equality using the non-static Equals method.

                Point3D point1 = new Point3D(10, 5, 1);
                Point3D point2 = new Point3D(15, 40, 60);
                Boolean areEqual;

                areEqual = point1.Equals(point2);
                // areEqual is False.  point2 is a Point3D structure, but it is not equal to point1.


                // Displaying Results
                syntaxString    = "areEqual = point1.Equals(point2);;";
                resultType      = "Boolean";
                operationString = "Checking if two 3D points are equal";
                ShowResults(areEqual.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN14>
                break;
            }


            case "rb13":
            {
                //<SnippetMil3DPoints3DN15>
                // Converts a string representation of a 3-D point into a Point3D structure.

                Point3D pointResult = new Point3D();

                pointResult = Point3D.Parse("1,3,5");
                // pointResult is equal to (1,3,5)

                // Displaying Results
                syntaxString    = "ointResult = Point3D.Parse(\"1,3,5\");";
                resultType      = "Matrix";
                operationString = "Converting a string into a Point3D structure.";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN15>
                break;
            }

            case "rb14":
            {
                //<SnippetMil3DPoints3DN16>
                // Checks if two Point3Ds are not equal using the overloaded inequality operator.

                Point3D point1 = new Point3D(10, 5, 1);
                Point3D point2 = new Point3D(15, 40, 60);
                Boolean areNotEqual;

                areNotEqual = (point1 != point2);
                // areNotEqual is True

                // Displaying Results
                syntaxString    = "areNotEqual = (point1 != point2);";
                resultType      = "Boolean";
                operationString = "Checking if two 3D points are not equal";
                ShowResults(areNotEqual.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN16>
                break;
            }

            case "rb15":
            {
                //<SnippetMil3DPoints3DN17>
                // Point3D Subtraction

                // instantiate variables
                Point3D  point1       = new Point3D();
                Point3D  point2       = new Point3D(15, 40, 60);
                Vector3D vector1      = new Vector3D(20, 30, 40);
                Point3D  pointResult  = new Point3D();
                Vector3D vectorResult = new Vector3D();

                // defining x,y,z of point1
                point1.X = 10;
                point1.Y = 5;
                point1.Z = 1;

                vectorResult = Point3D.Subtract(point1, point2);
                // vectorResult is equal to (-5, -35, -39)

                vectorResult = point2 - point1;
                // vectorResult is equal to (5, 35, 59)

                //pointResult = Point3D.Subtract(point1, vector1);
                //  pointResult is equal to (-10, -25, -39)

                pointResult = vector1 - point1;
                //  pointResult is equal to (10, 25, 39)


                // Displaying Results
                syntaxString    = "areNotEqual = (point1 != point2);";
                resultType      = "Boolean";
                operationString = "Checking if two 3D points are not equal";
                ShowResults(pointResult.ToString(), syntaxString, resultType, operationString);
                //</SnippetMil3DPoints3DN17>
                break;
            }

            default:
                break;
                //<SnippetMil3DPoints3DN2>
            } //end switch
        }
Example #30
0
 public bool Equals(Pupil other)
 {
     return(Left.Equals(other.Left) && Right.Equals(other.Right));
 }
 public void EqualsTest()
 {
     Point3D target = new Point3D(); // TODO: 初始化为适当的值
     object xObject = null; // TODO: 初始化为适当的值
     bool expected = false; // TODO: 初始化为适当的值
     bool actual;
     actual = target.Equals( xObject );
     Assert.AreEqual( expected, actual );
     Assert.Inconclusive( "验证此测试方法的正确性。" );
 }