Ejemplo n.º 1
0
 public void Tuple3_Properties()
 {
     var tuple = new Tuple3();
     tuple.X = 1.1;
     tuple.Y = 1.2;
     tuple.Z = 1.3;
     Assert.AreEqual(1.1, tuple.X);
     Assert.AreEqual(1.2, tuple.Y);
     Assert.AreEqual(1.3, tuple.Z);
 }
Ejemplo n.º 2
0
        public void Tuple3_Operators()
        {
            Assert.AreEqual(true, new Tuple3(1.0, 2.0, 3.0).Equals(new Tuple3(1.0, 2.0, 3.0)));
            Assert.AreEqual(false, new Tuple3(1.0, 2.0, 3.0).Equals(null));
            Assert.AreEqual(false, new Tuple2(1.0, 2.0).Equals("string"));
            Assert.AreEqual(false, new Tuple3(1.0, 2.0, 3.0).Equals(new Tuple3(0.0, 2.0, 3.0)));
            Assert.AreEqual(false, new Tuple3(1.0, 2.0, 3.0).Equals(new Tuple3(1.0, 0.0, 3.0)));
            Assert.AreEqual(false, new Tuple3(1.0, 2.0, 3.0).Equals(new Tuple3(1.0, 2.0, 0.0)));

            var tuple1 = new Tuple3(0.1, 0.2, 0.3) + new Tuple3(1.0, 2.0, 3.0);
            Assert.AreEqual(1.1, tuple1.X);
            Assert.AreEqual(2.2, tuple1.Y);
            Assert.AreEqual(3.3, tuple1.Z);

            var tuple2 = new Tuple3(1.1, 2.2, 3.3) - new Tuple3(0.1, 0.2, 0.3);
            Assert.AreEqual(1.0, tuple2.X);
            Assert.AreEqual(2.0, tuple2.Y);
            Assert.AreEqual(3.0, tuple2.Z);
        }
Ejemplo n.º 3
0
        public void Tuple3_Setters()
        {
            var tuple1 = new Tuple3();
            tuple1.Set(1.1, 1.2, 1.3);
            Assert.AreEqual(1.1, tuple1.X);
            Assert.AreEqual(1.2, tuple1.Y);
            Assert.AreEqual(1.3, tuple1.Z);

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

            var tuple3 = new Tuple3();
            tuple3.Set(new[] { 1.1, 1.2, 1.3 });
            Assert.AreEqual(1.1, tuple1.X);
            Assert.AreEqual(1.2, tuple1.Y);
            Assert.AreEqual(1.3, tuple1.Z);
        }
Ejemplo n.º 4
0
        public void Tuple3_Constructors()
        {
            var tuple1 = new Tuple3();
            Assert.AreEqual(0.0, tuple1.X);
            Assert.AreEqual(0.0, tuple1.Y);
            Assert.AreEqual(0.0, tuple1.Z);

            var tuple2 = new Tuple3(1.1, 1.2, 1.3);
            Assert.AreEqual(1.1, tuple2.X);
            Assert.AreEqual(1.2, tuple2.Y);
            Assert.AreEqual(1.3, tuple2.Z);

            var tuple3 = new Tuple3(new Tuple3(1.1, 1.2, 1.3));
            Assert.AreEqual(1.1, tuple3.X);
            Assert.AreEqual(1.2, tuple3.Y);
            Assert.AreEqual(1.3, tuple3.Z);

            var tuple4 = new Tuple3(new[] { 1.1, 1.2, 1.3 });
            Assert.AreEqual(1.1, tuple4.X);
            Assert.AreEqual(1.2, tuple4.Y);
            Assert.AreEqual(1.3, tuple4.Z);
        }
Ejemplo n.º 5
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="u"></param>
 /// <param name="v"></param>
 /// <returns></returns>
 public static Tuple3 Cross(Tuple3 u, Tuple3 v)
 {
     return new Tuple3((u.Y * v.Z) - (u.Z * v.Y), (u.Z * v.X) - (u.X * v.Z), (u.X * v.Y) - (u.Y * v.X));
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="u"></param>
 /// <param name="v"></param>
 /// <returns></returns>
 public static double Dot(Tuple3 u, Tuple3 v)
 {
     return (u.X * v.X) + (u.Y * v.Y) + (u.Z * v.Z);
 }
Ejemplo n.º 7
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="tuple"></param>
 public void Set(Tuple3 tuple)
 {
     x = tuple.x;
     y = tuple.y;
     z = tuple.z;
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="tuple"></param>
 public Tuple3(Tuple3 tuple)
 {
     Set(tuple);
 }