public void Construct2()
        {
            Matrix3D m = new Matrix3D(
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0,
                7.0, 8.0, 9.0);

            Assert.AreEqual(1.0, m.Column0Row0);
            Assert.AreEqual(2.0, m.Column1Row0);
            Assert.AreEqual(3.0, m.Column2Row0);
            Assert.AreEqual(4.0, m.Column0Row1);
            Assert.AreEqual(5.0, m.Column1Row1);
            Assert.AreEqual(6.0, m.Column2Row1);
            Assert.AreEqual(7.0, m.Column0Row2);
            Assert.AreEqual(8.0, m.Column1Row2);
            Assert.AreEqual(9.0, m.Column2Row2);

            Assert.AreEqual(1.0, m.ReadOnlyColumnMajorValues[0]);
            Assert.AreEqual(4.0, m.ReadOnlyColumnMajorValues[1]);
            Assert.AreEqual(7.0, m.ReadOnlyColumnMajorValues[2]);
            Assert.AreEqual(2.0, m.ReadOnlyColumnMajorValues[3]);
            Assert.AreEqual(5.0, m.ReadOnlyColumnMajorValues[4]);
            Assert.AreEqual(8.0, m.ReadOnlyColumnMajorValues[5]);
            Assert.AreEqual(3.0, m.ReadOnlyColumnMajorValues[6]);
            Assert.AreEqual(6.0, m.ReadOnlyColumnMajorValues[7]);
            Assert.AreEqual(9.0, m.ReadOnlyColumnMajorValues[8]);
        }
        public void Construct1()
        {
            Matrix3D m = new Matrix3D(1.0);

            for (int i = 0; i < m.NumberOfComponents; ++i)
            {
                Assert.AreEqual(1.0, m.ReadOnlyColumnMajorValues[0], 1e-14);
            }
        }
        public void DoubleToFloat()
        {
            Matrix3D m = new Matrix3D(
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0,
                7.0, 8.0, 9.0);

            Matrix3F mf = m.ToMatrix4F();

            Assert.AreEqual(1.0, mf.ReadOnlyColumnMajorValues[0], 1e-7);
            Assert.AreEqual(4.0, mf.ReadOnlyColumnMajorValues[1], 1e-7);
            Assert.AreEqual(7.0, mf.ReadOnlyColumnMajorValues[2], 1e-7);
            Assert.AreEqual(2.0, mf.ReadOnlyColumnMajorValues[3], 1e-7);
            Assert.AreEqual(5.0, mf.ReadOnlyColumnMajorValues[4], 1e-7);
            Assert.AreEqual(8.0, mf.ReadOnlyColumnMajorValues[5], 1e-7);
            Assert.AreEqual(3.0, mf.ReadOnlyColumnMajorValues[6], 1e-7);
            Assert.AreEqual(6.0, mf.ReadOnlyColumnMajorValues[7], 1e-7);
            Assert.AreEqual(9.0, mf.ReadOnlyColumnMajorValues[8], 1e-7);
        }
        /// <summary>
        /// Sets the <see cref="CenterPoint"/> and <see cref="FixedToLocalRotation"/> properties so that the
        /// camera is looking at a given longitude, latitude, and height and is oriented in that point's local
        /// East-North-Up frame.  This method does not change the <see cref="Azimuth"/>, <see cref="Elevation"/>,
        /// or <see cref="Range"/> properties, but the existing values of those properties are interpreted in the
        /// new reference frame.
        /// </summary>
        /// <param name="longitude">The longitude of the point to look at, in radians.</param>
        /// <param name="latitude">The latitude of the point to look at, in radians.</param>
        /// <param name="height">The height of the point to look at, in meters above the <see cref="Ellipsoid"/> surface.</param>
        public void ViewPoint(Ellipsoid ellipsoid, Geodetic3D geographic)
        {
            _centerPoint = ellipsoid.ToVector3D(geographic);
            
            // Fixed to East-North-Up rotation, from Wikipedia's "Geodetic System" topic.
            double cosLon = Math.Cos(geographic.Longitude);
            double cosLat = Math.Cos(geographic.Latitude);
            double sinLon = Math.Sin(geographic.Longitude);
            double sinLat = Math.Sin(geographic.Latitude);
            _fixedToLocalRotation =
                new Matrix3D(-sinLon,            cosLon,             0.0,
                             -sinLat * cosLon,   -sinLat * sinLon,   cosLat,
                             cosLat * cosLon,    cosLat * sinLon,    sinLat);

            UpdateCameraFromParameters();
        }
Exemple #5
0
        public bool Equals(Matrix3D other)
        {
            if (Matrix3D.ReferenceEquals(other, null))
            {
                return false;
            }

            for (int i = 0; i < _values.Length; ++i)
            {
                if (!_values[i].Equals(other._values[i]))
                {
                    return false;
                }
            }

            return true;
        }
        public void TestGetHashCode()
        {
            Matrix3D a = new Matrix3D(
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0,
                7.0, 8.0, 9.0).Transpose();
            Matrix3D b = new Matrix3D(0.0);
            Matrix3D c = new Matrix3D(
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0,
                7.0, 8.0, 9.0).Transpose();

            Assert.AreEqual(a.GetHashCode(), c.GetHashCode());
            Assert.AreNotEqual(a.GetHashCode(), b.GetHashCode());
        }
        public void Equals()
        {
            Matrix3D a = new Matrix3D(
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0,
                7.0, 8.0, 9.0).Transpose();
            Matrix3D b = new Matrix3D(0.0);
            Matrix3D c = new Matrix3D(
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0,
                7.0, 8.0, 9.0).Transpose();

            Assert.IsTrue(a.Equals(c));
            Assert.IsTrue(c.Equals(a));
            Assert.IsTrue(a == c);
            Assert.IsTrue(c == a);
            Assert.IsFalse(c != a);
            Assert.IsFalse(c != a);
            Assert.IsFalse(a.Equals(b));
            Assert.IsFalse(b.Equals(a));
            Assert.IsFalse(a == b);
            Assert.IsFalse(b == a);
            Assert.IsTrue(a != b);
            Assert.IsTrue(b != a);

            object objA = a;
            object objB = b;
            object objC = c;

            Assert.IsTrue(a.Equals(objA));
            Assert.IsTrue(a.Equals(objC));
            Assert.IsFalse(a.Equals(objB));

            Assert.IsTrue(objA.Equals(objC));
            Assert.IsFalse(objA.Equals(objB));

            Assert.IsFalse(a.Equals(null));
            Assert.IsFalse(a.Equals(5));
        }
 public void MultiplyVector2()
 {
     Matrix3D m = new Matrix3D(
         1.0, 0.0, 2.0,
         0.0, 1.0, 3.0,
         2.0, 0.0, 1.0);
     Vector3D v = new Vector3D(1.0, 2.0, 3.0);
     Vector3D result = new Vector3D(7.0, 11.0, 5.0);
     Assert.AreEqual(result, m * v);
 }
 public void MultiplyVector0()
 {
     Matrix3D zero = new Matrix3D(0.0);
     Vector3D v = new Vector3D(1.0, 2.0, 3.0);
     Assert.AreEqual(Vector3D.Zero, zero * v);
 }
        public void Transpose()
        {
            Matrix3D m = new Matrix3D(
                1.0, 2.0, 3.0,
                4.0, 5.0, 6.0,
                7.0, 8.0, 9.0).Transpose();

            Assert.AreEqual(1.0, m.Column0Row0);
            Assert.AreEqual(4.0, m.Column1Row0);
            Assert.AreEqual(7.0, m.Column2Row0);
            Assert.AreEqual(2.0, m.Column0Row1);
            Assert.AreEqual(5.0, m.Column1Row1);
            Assert.AreEqual(8.0, m.Column2Row1);
            Assert.AreEqual(3.0, m.Column0Row2);
            Assert.AreEqual(6.0, m.Column1Row2);
            Assert.AreEqual(9.0, m.Column2Row2);
        }