Esempio n. 1
0
        /// <summary>
        /// Create a new ParametricLine from a coordinates string on the format "(X Y Z A B C)".
        /// </summary>
        /// <param name="coordinates">Coordinates in the format "(X Y Z A B C)".</param>
        public ParametricLine(string coordinates)
        {
            try
            {
                double[] parsed = CoordinateConverter.ParseCoordinates(coordinates);
                if (parsed.Length != 6)
                {
                    throw new ArgumentException("The provided coordinates are not in the expected format '(X Y Z A B C)' and does not contains 3 values.", nameof(coordinates));
                }

                this.Point  = new Cartesian3dCoordinate(parsed[0], parsed[1], parsed[2]);
                this.Vector = new Cartesian3dCoordinate(parsed[3], parsed[4], parsed[5]);
            }
            catch (FormatException e)
            {
                throw new ArgumentException("The provided coordinates are not in the expected format '(X Y Z A B C)' and cannot be parsed.", nameof(coordinates), e);
            }
        }
        /// <summary>
        /// Create a new Cartesian3dCoordinate from a coordinates string on the format "(X Y)".
        /// </summary>
        /// <param name="coordinates">Coordinates in the format "(X Y)".</param>
        public Cartesian2dCoordinate(string coordinates)
        {
            try
            {
                double[] parsed = CoordinateConverter.ParseCoordinates(coordinates);
                if (parsed.Length != 2)
                {
                    throw new ArgumentException("The provided coordinates are not in the expected format '(X Y)' and does not contains 3 values.", nameof(coordinates));
                }

                this.X = parsed[0];
                this.Y = parsed[1];
            }
            catch (FormatException e)
            {
                throw new ArgumentException("The provided coordinates are not in the expected format '(X Y)' and cannot be parsed.", nameof(coordinates), e);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Create a new Plane from the coordiante in a string format.
        /// </summary>
        /// <param name="coordinates">Coordinates in the string format "(A B C D)".</param>
        public Plane(string coordinates)
        {
            try
            {
                double[] parsed = CoordinateConverter.ParseCoordinates(coordinates);
                if (parsed.Length != 4)
                {
                    throw new ArgumentException("The provided coordinates are not in the expected format '(A B C D)' and does not contains 4 values.", nameof(coordinates));
                }

                this.Normal = new Cartesian3dCoordinate(parsed[0], parsed[1], parsed[2]);
                this.D      = parsed[3];
            }
            catch (FormatException e)
            {
                throw new ArgumentException("The provided coordinates are not in the expected format '(A B C D)' and cannot be parsed.", nameof(coordinates), e);
            }
        }