public void CoordinateConverter_ConvertFromHomogeneousToCartesian_BeExpected(double hx, double hy, double hz, double hw, double x, double y, double z)
        {
            // 1. Prepare
            HomogeneousCoordinate hc = new HomogeneousCoordinate(hx, hy, hz, hw);

            // 2. Execute
            Cartesian3dCoordinate cc = CoordinateConverter.ConvertToCartesian(hc);

            // 3. Verify
            Assert.Equal(x, cc.X, PRECISION_DOUBLE);
            Assert.Equal(y, cc.Y, PRECISION_DOUBLE);
            Assert.Equal(z, cc.Z, PRECISION_DOUBLE);
        }
        public void CoordinateConverter_ConvertFromSphericalToCartesian_BeExpected(double phi, double theta, double x, double y, double z)
        {
            // 1. Prepare
            SphericalVector sc = new SphericalVector(phi, theta);

            // 2. Execute
            Cartesian3dCoordinate cc = CoordinateConverter.ConvertToCartesian(sc);

            // 3. Verify
            Assert.Equal(x, cc.X, PRECISION_DOUBLE);
            Assert.Equal(y, cc.Y, PRECISION_DOUBLE);
            Assert.Equal(z, cc.Z, PRECISION_DOUBLE);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets a block face based on its orientation.
        /// </summary>
        /// <param name="o">Vector indicating the orientation of the face we try to get.</param>
        /// <returns>The searched Blockface if found, otherwise, null is returned.</returns>
        public BlockFace GetBlockFace(SphericalVector o)
        {
            if (o == null)
            {
                throw new ArgumentNullException("Orientation is mandatory", nameof(o));
            }

            return(m_Faces.FirstOrDefault(f => this.Orientation.Rotate(f.Position).IsSameVector(CoordinateConverter.ConvertToCartesian(o))));
        }
Esempio n. 4
0
 /// <summary>
 /// Create a new objet representing a block face.
 /// </summary>
 /// <param name="identifier">Identifier of the BlockFaces that should match the expected face.</param>
 /// <param name="p"></param>
 public BlockFace(string identifier, SphericalVector p)
 {
     this.Position = CoordinateConverter.ConvertToCartesian(p);
     this.Id       = identifier;
 }