/// <summary>
        /// Rotate the current vector around a specified vector from a defined angle in radians.
        /// </summary>
        /// <param name="v">Vector used as a rotation axis.</param>
        /// <param name="theta">Angle of rotation expressed in radians.</param>
        /// <returns>The coordinates of the resulting rotated vector.</returns>
        public SphericalVector RotateAround(SphericalVector v, double theta)
        {
            if (theta.IsZero())
            {
                return(this);
            }

            return(CoordinateConverter.ConvertToSpherical(CoordinateConverter.ConvertToCartesian(this).RotateAroundVector(CoordinateConverter.ConvertToCartesian(v), theta)));
        }
        /// <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);
            }
        }
Beispiel #3
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);
            }
        }
Beispiel #4
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);
            }
        }
 /// <summary>
 /// Compares two objects and returns a value indicating whether one is less than, equal to, or greater than the other.
 /// </summary>
 /// <param name="x">The first object to compare.</param>
 /// <param name="y">The second object to compare.</param>
 /// <returns>
 /// A signed integer that indicates the relative values of x and y:
 /// - If less than 0, x is less than y.
 /// - If 0, x equals y.
 /// - If greater than 0, x is greater than y.
 /// </returns>
 public int Compare(SphericalVector x, SphericalVector y)
 {
     return(this.Compare(CoordinateConverter.ConvertToCartesian(x), CoordinateConverter.ConvertToCartesian(y)));
 }