Exemplo n.º 1
0
        /// <summary>
        /// Возвращает строковое представлеине данной матрицы.
        /// </summary>
        /// <returns>Строковое представлеине данной матрицы.</returns>
        /// <remarks>
        /// <code>
        /// var matrix = Matrix3D.GetRotation(Math.PI, new Point3D(1, 1, 1));
        /// Console.Write(matrix); //Результат: -1/3 2/3 2/3 | 2/3 -1/3 2/3 | 2/3 2/3 -1/3
        /// </code>
        /// </remarks>
        public override string ToString()
        {
            if (IsNaN)
            {
                return("NaN");
            }

            return
                (CStatic.DoubleToString(Line1.X) + CStatic.EmSp +
                 CStatic.DoubleToString(Line1.Y) + CStatic.EmSp +
                 CStatic.DoubleToString(Line1.Z) + CStatic.EmSp +
                 "|" + CStatic.EmSp +
                 CStatic.DoubleToString(Line2.X) + CStatic.EmSp +
                 CStatic.DoubleToString(Line2.Y) + CStatic.EmSp +
                 CStatic.DoubleToString(Line2.Z) + CStatic.EmSp +
                 "|" + CStatic.EmSp +
                 CStatic.DoubleToString(Line3.X) + CStatic.EmSp +
                 CStatic.DoubleToString(Line3.Y) + CStatic.EmSp +
                 CStatic.DoubleToString(Line3.Z));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Возвращает строковое представлеине данного линейного уравнения.
        /// </summary>
        /// <returns>Строковое представление данного линейного уравнения.</returns>
        /// <remarks>
        /// <code>
        /// var linear = new Linear(new double[] {3, 1, -1}, -4);
        /// Console.Write(linear); //Результат: 3 x₁ + x₂ - x₃ = -4
        /// Console.Write(-linear/3); //Результат: -x₁ - 1/3 x₂ + 1/3 x₃ = 4/3
        /// </code>
        /// </remarks>
        public override string ToString()
        {
            var result = CStatic.GetToStringHashValue(this);

            if (result != null)
            {
                return(result);
            }
            result = "";


            for (var i = 0; i < A.Length; i++)
            {
                var sym = "x" + CStatic.GetIndex(i + 1);
                CStatic.AddLinearItem(ref result, A[i], sym);
            }
            result  = result == "" ? "0" : result;
            result += " = " + CStatic.DoubleToString(Y);


            CStatic.AddToStringHashValue(this, result);
            return(result);
        }