Пример #1
0
 public void Tuple2_Properties()
 {
     var tuple = new Tuple2();
     tuple.X = 1.1;
     tuple.Y = 1.2;
     Assert.AreEqual(1.1, tuple.X);
     Assert.AreEqual(1.2, tuple.Y);
 }
Пример #2
0
        public void Tuple2_Setters()
        {
            var tuple1 = new Tuple2();
            tuple1.Set(1.1, 1.2);
            Assert.AreEqual(1.1, tuple1.X);
            Assert.AreEqual(1.2, tuple1.Y);

            var tuple2 = new Tuple2();
            tuple2.Set(new Tuple2(1.1, 1.2));
            Assert.AreEqual(1.1, tuple1.X);
            Assert.AreEqual(1.2, tuple1.Y);

            var tuple3 = new Tuple2();
            tuple3.Set(new[] { 1.1, 1.2 });
            Assert.AreEqual(1.1, tuple1.X);
            Assert.AreEqual(1.2, tuple1.Y);
        }
Пример #3
0
        public void Tuple2_Operators()
        {

            Assert.AreEqual(true, new Tuple2(1.0, 2.0).Equals(new Tuple2(1.0, 2.0)));
            Assert.AreEqual(false, new Tuple2(1.0, 2.0).Equals(null));
            Assert.AreEqual(false, new Tuple2(1.0, 2.0).Equals("string"));
            Assert.AreEqual(false, new Tuple2(1.0, 2.0).Equals(new Tuple2(0.0, 2.0)));
            Assert.AreEqual(false, new Tuple2(1.0, 2.0).Equals(new Tuple2(1.0, 0.0)));

            var tuple1 = new Tuple2(0.1, 0.2) + new Tuple2(1.0, 2.0);
            Assert.AreEqual(1.1, tuple1.X);
            Assert.AreEqual(2.2, tuple1.Y);

            var tuple2 = new Tuple2(1.1, 2.2) - new Tuple2(0.1, 0.2);
            Assert.AreEqual(1.0, tuple2.X);
            Assert.AreEqual(2.0, tuple2.Y);
        }
Пример #4
0
        public void Tuple2_Constructors()
        {
            var tuple1 = new Tuple2();
            Assert.AreEqual(0.0, tuple1.X);
            Assert.AreEqual(0.0, tuple1.Y);

            var tuple2 = new Tuple2(1.1, 1.2);
            Assert.AreEqual(1.1, tuple2.X);
            Assert.AreEqual(1.2, tuple2.Y);

            var tuple3 = new Tuple2(new Tuple2(1.1, 1.2));
            Assert.AreEqual(1.1, tuple3.X);
            Assert.AreEqual(1.2, tuple3.Y);

            var tuple4 = new Tuple2(new[] { 1.1, 1.2 });
            Assert.AreEqual(1.1, tuple4.X);
            Assert.AreEqual(1.2, tuple4.Y);
        }
Пример #5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="tuple"></param>
 public Tuple2(Tuple2 tuple)
 {
     Set(tuple);
 }
Пример #6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="u"></param>
 /// <param name="v"></param>
 /// <returns></returns>
 public static double Dot(Tuple2 u, Tuple2 v)
 {
     return (u.X * v.X) + (u.Y * v.Y);
 }
Пример #7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="tuple"></param>
 public void Set(Tuple2 tuple)
 {
     x = tuple.x;
     y = tuple.y;
 }